diff --git a/controllers/class.Cron.php b/controllers/class.Cron.php
index 135a227dc..9bada6bb6 100644
--- a/controllers/class.Cron.php
+++ b/controllers/class.Cron.php
@@ -58,10 +58,14 @@ class SeedDMS_Controller_Cron extends SeedDMS_Controller_Common {
if($taskobj->execute($task)) {
add_log_line("Execution of task ".$task->getExtension()."::".$task->getTask()." successful.");
$arr['success'] = true;
+ $task->resetFailures();
} else {
add_log_line("Execution of task ".$task->getExtension()."::".$task->getTask()." failed, task has been disabled.", PEAR_LOG_ERR);
$arr['success'] = false;
- $task->setDisabled(1);
+ if($task->getFailures() > 5)
+ $task->setDisabled(1);
+ else
+ $task->incFailures();
}
} elseif($mode == 'dryrun') {
$arr['success'] = true;
diff --git a/inc/inc.ClassSchedulerTask.php b/inc/inc.ClassSchedulerTask.php
index 5c19dda7a..d72114384 100644
--- a/inc/inc.ClassSchedulerTask.php
+++ b/inc/inc.ClassSchedulerTask.php
@@ -90,7 +90,7 @@ class SeedDMS_SchedulerTask {
return null;
$row = $resArr[0];
- $task = new self($row["id"], $row['name'], $row["description"], $row["extension"], $row["task"], $row["frequency"], $row['disabled'], json_decode($row['params'], true), $row["nextrun"], $row["lastrun"]);
+ $task = new self($row["id"], $row['name'], $row["description"], $row["extension"], $row["task"], $row["frequency"], $row['disabled'], json_decode($row['params'], true), $row["nextrun"], $row["lastrun"], $row["failures"]);
$task->setDB($db);
return $task;
@@ -106,7 +106,7 @@ class SeedDMS_SchedulerTask {
$tasks = array();
foreach($resArr as $row) {
- $task = new self($row["id"], $row['name'], $row["description"], $row["extension"], $row["task"], $row["frequency"], $row['disabled'], json_decode($row['params'], true), $row["nextrun"], $row["lastrun"]);
+ $task = new self($row["id"], $row['name'], $row["description"], $row["extension"], $row["task"], $row["frequency"], $row['disabled'], json_decode($row['params'], true), $row["nextrun"], $row["lastrun"], $row["failures"]);
$task->setDB($db);
$tasks[] = $task;
}
@@ -124,7 +124,7 @@ class SeedDMS_SchedulerTask {
$tasks = array();
foreach($resArr as $row) {
- $task = new self($row["id"], $row['name'], $row["description"], $row["extension"], $row["task"], $row["frequency"], $row['disabled'], json_decode($row['params'], true), $row["nextrun"], $row["lastrun"]);
+ $task = new self($row["id"], $row['name'], $row["description"], $row["extension"], $row["task"], $row["frequency"], $row['disabled'], json_decode($row['params'], true), $row["nextrun"], $row["lastrun"], $row["failures"]);
$task->setDB($db);
$tasks[] = $task;
}
@@ -132,7 +132,7 @@ class SeedDMS_SchedulerTask {
return $tasks;
} /* }}} */
- function __construct($id, $name, $description, $extension, $task, $frequency, $disabled, $params, $nextrun, $lastrun) {
+ function __construct($id, $name, $description, $extension, $task, $frequency, $disabled, $params, $nextrun, $lastrun, $failures) {
$this->_id = $id;
$this->_name = $name;
$this->_description = $description;
@@ -143,6 +143,7 @@ class SeedDMS_SchedulerTask {
$this->_params = $params;
$this->_nextrun = $nextrun;
$this->_lastrun = $lastrun;
+ $this->_failures = $failures;
}
public function setDB($db) {
@@ -225,6 +226,34 @@ class SeedDMS_SchedulerTask {
return $this->_lastrun;
}
+ public function getFailures() {
+ return $this->_failures;
+ }
+
+ public function resetFailures() { /* {{{ */
+ $db = $this->db;
+
+ $queryStr = "UPDATE `tblSchedulerTask` SET `failures` = 0 WHERE `id` = " . $this->_id;
+ $res = $db->getResult($queryStr);
+ if (!$res)
+ return false;
+
+ $this->_failures = 0;
+ return true;
+ } /* }}} */
+
+ public function incFailures() { /* {{{ */
+ $db = $this->db;
+
+ $queryStr = "UPDATE `tblSchedulerTask` SET `failures` = ".($this->_failures+1)." WHERE `id` = " . $this->_id;
+ $res = $db->getResult($queryStr);
+ if (!$res)
+ return false;
+
+ $this->_failures++;
+ return true;
+ } /* }}} */
+
public function getDisabled() {
return $this->_disabled;
}
diff --git a/install/create_tables-innodb.sql b/install/create_tables-innodb.sql
index a18f77cd6..368398008 100644
--- a/install/create_tables-innodb.sql
+++ b/install/create_tables-innodb.sql
@@ -1025,6 +1025,7 @@ CREATE TABLE `tblSchedulerTask` (
`params` text DEFAULT NULL,
`nextrun` datetime DEFAULT NULL,
`lastrun` datetime DEFAULT NULL,
+ `failures` int(11) DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
diff --git a/install/create_tables-postgres.sql b/install/create_tables-postgres.sql
index 015e212f5..91134e722 100644
--- a/install/create_tables-postgres.sql
+++ b/install/create_tables-postgres.sql
@@ -833,7 +833,8 @@ CREATE TABLE "tblSchedulerTask" (
"frequency" varchar(100) DEFAULT NULL,
"params" TEXT DEFAULT NULL,
"nextrun" TIMESTAMP DEFAULT NULL,
- "lastrun" TIMESTAMP DEFAULT NULL
+ "lastrun" TIMESTAMP DEFAULT NULL,
+ "failures" INTEGER DEFAULT '0'
) ;
-- --------------------------------------------------------
diff --git a/install/create_tables-sqlite3.sql b/install/create_tables-sqlite3.sql
index d0d9ac18e..676d50187 100644
--- a/install/create_tables-sqlite3.sql
+++ b/install/create_tables-sqlite3.sql
@@ -842,7 +842,8 @@ CREATE TABLE `tblSchedulerTask` (
`frequency` varchar(100) DEFAULT NULL,
`params` TEXT DEFAULT NULL,
`nextrun` TEXT DEFAULT NULL,
- `lastrun` TEXT DEFAULT NULL
+ `lastrun` TEXT DEFAULT NULL,
+ `failures` INTEGER DEFAULT '0'
) ;
-- --------------------------------------------------------
diff --git a/install/update-6.1.0/update-postgres.sql b/install/update-6.1.0/update-postgres.sql
index 71dbf93c2..f5c6168fb 100644
--- a/install/update-6.1.0/update-postgres.sql
+++ b/install/update-6.1.0/update-postgres.sql
@@ -24,6 +24,8 @@ ALTER TABLE "tblCategory" ADD COLUMN "color" char(8) default NULL;
ALTER TABLE "tblNotify" ADD COLUMN "inherit" INTEGER NOT NULL default '0';
+ALTER TABLE "tblSchedulerTask" ADD COLUMN "failures" INTEGER NOT NULL default '0';
+
CREATE TABLE "tblAttributeDefinitionGroups" (
"id" SERIAL UNIQUE,
"name" varchar(100) default NULL,
diff --git a/install/update-6.1.0/update-sqlite3.sql b/install/update-6.1.0/update-sqlite3.sql
index 39b0662c2..981913d1f 100644
--- a/install/update-6.1.0/update-sqlite3.sql
+++ b/install/update-6.1.0/update-sqlite3.sql
@@ -70,6 +70,8 @@ ALTER TABLE `tblCategory` ADD COLUMN `color` char(8) DEFAULT NULL;
ALTER TABLE `tblNotify` ADD COLUMN `inherit` INTEGER NOT NULL DEFAULT '0';
+ALTER TABLE `tblSchedulerTask` ADD COLUMN `failures` INTEGER NOT NULL DEFAULT '0';
+
CREATE TABLE `tblAttributeDefinitionGroups` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`name` varchar(100) default NULL,
diff --git a/install/update-6.1.0/update.sql b/install/update-6.1.0/update.sql
index 6cc49a573..a6ab2a1fc 100644
--- a/install/update-6.1.0/update.sql
+++ b/install/update-6.1.0/update.sql
@@ -24,6 +24,8 @@ ALTER TABLE `tblCategory` ADD COLUMN `color` char(8) DEFAULT NULL AFTER `name`;
ALTER TABLE `tblNotify` ADD COLUMN `inherit` smallint(1) NOT NULL DEFAULT '0';
+ALTER TABLE `tblSchedulerTask` ADD COLUMN `failures` int(11) NOT NULL DEFAULT '0';
+
CREATE TABLE `tblAttributeDefinitionGroups` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) DEFAULT NULL,
diff --git a/views/bootstrap/class.SchedulerTaskMgr.php b/views/bootstrap/class.SchedulerTaskMgr.php
index 99456545b..b71f59b41 100644
--- a/views/bootstrap/class.SchedulerTaskMgr.php
+++ b/views/bootstrap/class.SchedulerTaskMgr.php
@@ -563,6 +563,8 @@ $(document).ready( function() {
echo " ".getLongReadableDate(makeTsFromDate($task->getNextRun()));
if($task->getLastRun())
echo "
".getLongReadableDate(makeTsFromDate($task->getLastRun()));
+ if($task->getFailures())
+ echo "
".$task->getFailures()." ".getMLText('task_failures');
echo "
".$task->getFrequency();
echo "";
echo "