Merge pull request #22680 from OPEN-DSI/14.0_fix_start_cron_in_multientities_with_verif_test_condition

FIX: Fix the position of the verification condition of the test field in case of multi entities
This commit is contained in:
Laurent Destailleur 2022-11-25 16:34:27 +01:00 committed by GitHub
commit 03485a2f73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 22 deletions

View File

@ -132,26 +132,18 @@ if ($result < 0) {
exit;
}
$qualifiedjobs = array();
foreach ($object->lines as $val) {
if (!verifCond($val->test)) {
continue;
}
$qualifiedjobs[] = $val;
}
// TODO Duplicate code. This sequence of code must be shared with code into cron_run_jobs.php script.
// current date
$nbofjobs = count($qualifiedjobs);
$nbofjobs = count($object->lines);
$nbofjobslaunchedok = 0;
$nbofjobslaunchedko = 0;
if (is_array($qualifiedjobs) && (count($qualifiedjobs) > 0)) {
if (is_array($object->lines) && (count($object->lines) > 0)) {
$savconf = dol_clone($conf);
// Loop over job
foreach ($qualifiedjobs as $line) {
foreach ($object->lines as $line) {
dol_syslog("cron_run_jobs.php cronjobid: ".$line->id." priority=".$line->priority." entity=".$line->entity." label=".$line->label, LOG_DEBUG);
echo "cron_run_jobs.php cronjobid: ".$line->id." priority=".$line->priority." entity=".$line->entity." label=".$line->label;
@ -181,6 +173,10 @@ if (is_array($qualifiedjobs) && (count($qualifiedjobs) > 0)) {
}
}
if (!verifCond($line->test)) {
continue;
}
//If date_next_jobs is less of current date, execute the program, and store the execution time of the next execution in database
if (($line->datenextrun < $now) && (empty($line->datestart) || $line->datestart <= $now) && (empty($line->dateend) || $line->dateend >= $now)) {
echo " - qualified";

View File

@ -173,25 +173,17 @@ if ($result < 0) {
exit(-1);
}
$qualifiedjobs = array();
foreach ($object->lines as $val) {
if (!verifCond($val->test)) {
continue;
}
$qualifiedjobs[] = $val;
}
// TODO Duplicate code. This sequence of code must be shared with code into public/cron/cron_run_jobs.php php page.
$nbofjobs = count($qualifiedjobs);
$nbofjobs = count($object->lines);
$nbofjobslaunchedok = 0;
$nbofjobslaunchedko = 0;
if (is_array($qualifiedjobs) && (count($qualifiedjobs) > 0)) {
if (is_array($object->lines) && (count($object->lines) > 0)) {
$savconf = dol_clone($conf);
// Loop over job
foreach ($qualifiedjobs as $line) {
foreach ($object->lines as $line) {
dol_syslog("cron_run_jobs.php cronjobid: ".$line->id." priority=".$line->priority." entity=".$line->entity." label=".$line->label, LOG_DEBUG);
echo "cron_run_jobs.php cronjobid: ".$line->id." priority=".$line->priority." entity=".$line->entity." label=".$line->label;
@ -233,6 +225,10 @@ if (is_array($qualifiedjobs) && (count($qualifiedjobs) > 0)) {
}
}
if (!verifCond($line->test)) {
continue;
}
//If date_next_jobs is less of current date, execute the program, and store the execution time of the next execution in database
if (($line->datenextrun < $now) && (empty($line->datestart) || $line->datestart <= $now) && (empty($line->dateend) || $line->dateend >= $now)) {
echo " - qualified";