contributions/scheduler/behaviour/commands/base/cleanupscheduler.cmd.php
Go to the documentation of this file.00001 <?php 00002 Load::commands('scheduler/process'); 00003 00004 /** 00005 * Find tasks that have crashed and treat them as failed 00006 * 00007 * @author Gerd Riesselmann 00008 */ 00009 class CleanupSchedulerBaseCommand extends ProcessSchedulerCommand { 00010 /** 00011 * Does processing 00012 */ 00013 protected function do_execute() { 00014 $ret = new Status(); 00015 00016 $tasks = new DAOScheduler(); 00017 $tasks->status = Scheduler::STATUS_PROCESSING; 00018 $tasks->add_where('scheduledate', '<', time() - 2 * GyroDate::ONE_HOUR); 00019 $tasks->find(); 00020 $err = new Status(tr('Task has crashed, possible out of memory or time', 'scheduler')); 00021 while ($tasks->fetch()) { 00022 $ret->merge($this->on_error(clone($tasks), $err)); 00023 if ($ret->is_error()) { 00024 break; 00025 } 00026 } 00027 return $ret; 00028 } 00029 00030 /** 00031 * Returns title of command. 00032 */ 00033 public function get_name() { 00034 return 'cleanup'; 00035 } 00036 00037 /** 00038 * Returns a description of this command 00039 */ 00040 public function get_description() { 00041 return tr('Cleanup', 'scheduler'); 00042 } 00043 }