Possible frequency bug in Acron plugin

The problem

If you try to set up the frequency element of a task with more than one attribute (minute, hour, day, month, dayofweek), acron plugin will take into account only the first attribute, ignoring the others.

For example, if I want “classes.tasks.ReviewReminder” to be run once a day at around 07:30, this will not work as expected:

<frequency minute="30" hour="7" day="*" month="*" dayofweek="*"/>

(from “registry/scheduledTasks.xml”)

the code in https://github.com/pkp/pkp-lib/blob/main/plugins/generic/acron/PKPAcronPlugin.inc.php, specifically this line:

$frequency = new XMLNode();
$frequency->setAttribute(key($task['frequency']), current($task['frequency']));
$canExecute = ScheduledTaskHelper::checkFrequency($task['className'], $frequency);`

will only send the first attribute (minute=“30”).

And so, this task keeps running every hour and 30 minutes (0:30, 1:30, 2:30,…23:30), ignoring the hour=“7” attribute.

The code in https://github.com/pkp/pkp-lib/blob/main/classes/cliTool/ScheduledTaskTool.inc.php is fine, because it sends all the attributes:

$className = $task->getAttribute('class');
$frequency = $task->getChildByName('frequency');
if (isset($frequency)) {
  $canExecute = ScheduledTaskHelper::checkFrequency($className, $frequency);
}

I found this because the schedule log files were being generated every hour and “last_run” on “scheduled_tasks” table was also being updated every hour, after minute 30.

Possible easy solution is to change the code in “PKPAcronPlugin.inc.php” to this:

$frequency = new XMLNode();
foreach($task['frequency'] as $key => $value) {
	$frequency->setAttribute($key, $value);
}
$canExecute = ScheduledTaskHelper::checkFrequency($task['className'], $frequency);

Application Version - all OJS versions