mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Fix add a protection to be able to process jobs not closed correctly.
This commit is contained in:
parent
94a8b85d8d
commit
335c5761f9
|
|
@ -167,7 +167,7 @@ if (isset($argv[4]) && $argv[4] == '--force') {
|
|||
$forcequalified = 1;
|
||||
}
|
||||
|
||||
// create a jobs object
|
||||
// Create a jobs object
|
||||
$object = new Cronjob($db);
|
||||
|
||||
$filter = array();
|
||||
|
|
@ -180,6 +180,15 @@ if (!empty($id)) {
|
|||
$filter['t.rowid'] = $id;
|
||||
}
|
||||
|
||||
|
||||
// Update old jobs that were not closed correctly so processing is moved from 1 to 0 (otherwise task stopped with fatal error are always in status "in progress")
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."cronjob set processing = 0";
|
||||
$sql .= " WHERE processing = 1";
|
||||
$sql .= " AND datelastrun <= '".$db->idate(dol_now() - 24*3600, 'gmt')."'";
|
||||
$sql .= " AND datelastresult IS NULL";
|
||||
$db->query($sql);
|
||||
|
||||
|
||||
$result = $object->fetchAll('ASC,ASC,ASC', 't.priority,t.entity,t.rowid', 0, 0, 1, $filter, 0);
|
||||
if ($result < 0) {
|
||||
echo "Error: ".$object->error;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user