-
-
Notifications
You must be signed in to change notification settings - Fork 530
Description
Bug report
Summary
In the Captcha package, there is one validator, it prints a message that appears three times when the package is installed or re-installed.
Step to reproduce
Install or reinstall the current version of captcha
Observed behavior
This appears in the console (the log message is in the validator):
Running PHP Validator.
Running PHP Validator.
Running PHP Validator.
I believe I've seen this with resolvers as well. Unless I'm doing something wrong (entirely possible), this may be happening regularly. Without a progress message, it would not be noticed.
It's happening in MODX 2 and MODX 3. I don't think this happened with earlier versions of MODX and the package has not changed for a few years.
Expected behavior
Validator should run once.
Code
Here's the relevant code in the transport package. It is not inside a loop.
/* @var $c modPlugin */
$c= $modx->newObject('modPlugin');
$c->set('id',1);
$c->set('name', 'Captcha');
$c->set('description', 'CAPTCHA Plugin');
$c->set('category', 0);
$c->set('plugincode', file_get_contents($sources['source_core'] . '/plugin.captcha.php'));
/* create a transport vehicle for the data object */
/* add plugin events */
$modx->log(xPDO::LOG_LEVEL_INFO,'Packaging in Plugin Events...');
$events = include $sources['data'].'plugin.events.php';
if (is_array($events) && !empty($events)) {
$c->addMany($events);
} else {
$modx->log(xPDO::LOG_LEVEL_ERROR,'Could not find plugin events!');
}
$modx->log(xPDO::LOG_LEVEL_INFO,'Plugin Events Packaged...');
$modx->log(xPDO::LOG_LEVEL_INFO,'Setting Package Attributes...');
$attributes= array(
xPDOTransport::ABORT_INSTALL_ON_VEHICLE_FAIL => true,
xPDOTransport::UNIQUE_KEY => 'name',
xPDOTransport::PRESERVE_KEYS => false,
xPDOTransport::UPDATE_OBJECT => true,
xPDOTransport::RELATED_OBJECTS => true,
xPDOTransport::RELATED_OBJECT_ATTRIBUTES => array (
'PluginEvents' => array(
xPDOTransport::PRESERVE_KEYS => true,
xPDOTransport::UPDATE_OBJECT => true,
xPDOTransport::UNIQUE_KEY => array('pluginid','event'),
),
),
);
$modx->log(xPDO::LOG_LEVEL_INFO,'Package Attributes Set...');
$modx->log(xPDO::LOG_LEVEL_INFO,'Creating Vehicle...');
$vehicle = $builder->createVehicle($c, $attributes);
$vehicle->validate('php',array(
'type' => 'php',
'source' => $sources['build'] . 'preinstall.script.php'
));
$vehicle->resolve('file',array(
'source' => $sources['source_assets'],
'target' => "return MODX_ASSETS_PATH . '/components/';",
));
$vehicle->resolve('file',array(
'source' => $sources['source_core'],
'target' => "return MODX_CORE_PATH . '/components/';",
));
$builder->putVehicle($vehicle);