Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix for the scheduler actions due SQL, it hasn't been picking tasks p…

…roperly since the laststarted field was added
  • Loading branch information...
commit 9a9489ee28a560989b0d627e4fc1c466f2942210 1 parent 1d2bb0b
@ericthefish ericthefish authored paulheaney committed
Showing with 7 additions and 4 deletions.
  1. +7 −4 lib/functions.inc.php
View
11 lib/functions.inc.php
@@ -5692,8 +5692,8 @@ function schedule_actions_due()
$actions = FALSE;
$sql = "SELECT * FROM `{$dbScheduler}` WHERE status = 'enabled' AND type = 'interval' ";
$sql .= "AND UNIX_TIMESTAMP(start) <= $now AND (UNIX_TIMESTAMP(end) >= $now OR UNIX_TIMESTAMP(end) = 0) ";
- $sql .= "AND IF(UNIX_TIMESTAMP(lastran) > 0, UNIX_TIMESTAMP(lastran) + `interval` <= $now, UNIX_TIMESTAMP(NOW())) ";
- $sql .= "AND laststarted <= lastran";
+ $sql .= "AND IF(UNIX_TIMESTAMP(lastran) > 0, UNIX_TIMESTAMP(lastran) + `interval` <= $now, 1=1) ";
+ $sql .= "AND IF(laststarted > 0, laststarted <= lastran, 1=1)";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
if (mysql_num_rows($result) > 0)
@@ -5704,12 +5704,14 @@ function schedule_actions_due()
}
}
+ echo $sql;
+
// Month
$sql = "SELECT * FROM `{$dbScheduler}` WHERE status = 'enabled' AND type = 'date' ";
$sql .= "AND UNIX_TIMESTAMP(start) <= $now AND (UNIX_TIMESTAMP(end) >= $now OR UNIX_TIMESTAMP(end) = 0) ";
$sql .= "AND ((date_type = 'month' AND (DAYOFMONTH(CURDATE()) > date_offset OR (DAYOFMONTH(CURDATE()) = date_offset AND CURTIME() >= date_time)) ";
$sql .= "AND DATE_FORMAT(CURDATE(), '%Y-%m') != DATE_FORMAT(lastran, '%Y-%m') ) ) "; // not run this month
- $sql .= "AND laststarted <= lastran";
+ $sql .= "AND IF(laststarted > 0, laststarted <= lastran, 1=1)";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
if (mysql_num_rows($result) > 0)
@@ -5727,7 +5729,7 @@ function schedule_actions_due()
$sql .= "AND ((date_type = 'year' AND (DAYOFYEAR(CURDATE()) > date_offset ";
$sql .= "OR (DAYOFYEAR(CURDATE()) = date_offset AND CURTIME() >= date_time)) ";
$sql .= "AND DATE_FORMAT(CURDATE(), '%Y') != DATE_FORMAT(lastran, '%Y') ) ) "; // not run this year
- $sql .= "AND laststarted <= lastran";
+ $sql .= "AND IF(laststarted > 0, laststarted <= lastran, 1=1)";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
@@ -5739,6 +5741,7 @@ function schedule_actions_due()
}
}
+ debug_log('actions'.print_r($actions,true));
return $actions;
}
Please sign in to comment.
Something went wrong with that request. Please try again.