コード例 #1
0
 /**
  * Actually execute the cronjob.
  * 
  * @param	array		$cronjobsCache
  * @return	boolean		success
  */
 protected function execPendingCronjobs($cronjobsCache = array())
 {
     // include class file
     if (!file_exists(WCF_DIR . $cronjobsCache['classPath'])) {
         throw new SystemException("unable to find class file '" . WCF_DIR . $cronjobsCache['classPath'] . "'", 11000);
     }
     require_once WCF_DIR . $cronjobsCache['classPath'];
     $i = 0;
     while ($i < $this->countMultipleExecs) {
         // omit 1970-01-01T01:00:00.
         if ($this->execMultiple == 1) {
             $cronjobsCache['nextExec'] = $this->timebase;
         }
         if (isset($this->plannedExecs) && count($this->plannedExecs)) {
             $cronjobsCache['nextExec'] = $this->plannedExecs[$i];
         }
         // create instance.
         $className = StringUtil::getClassName($cronjobsCache['classPath']);
         if (!class_exists($className)) {
             throw new SystemException("unable to find class '" . $className . "'", 11001);
         }
         // execute cronjob.
         $cronjobExec = new $className();
         if (method_exists($cronjobExec, 'execute')) {
             $cronjobExec->execute($cronjobsCache);
         }
         // log success.
         CronjobEditor::logSuccess($cronjobsCache['newLogID'], true);
         $i++;
     }
 }
コード例 #2
0
 /**
  * Executes this cronjob.
  */
 public function execute()
 {
     // create log entry
     $logID = CronjobEditor::logExec();
     // include class file
     $classPath = FileUtil::getRealPath(WCF_DIR . $this->packageDir . $this->classPath);
     if (!file_exists($classPath)) {
         throw new SystemException("unable to find class file '" . $classPath . "'", 11000);
     }
     require_once $classPath;
     // create instance.
     $className = StringUtil::getClassName($this->classPath);
     if (!class_exists($className)) {
         throw new SystemException("unable to find class '" . $className . "'", 11001);
     }
     // execute cronjob.
     $cronjobExec = new $className();
     if (method_exists($cronjobExec, 'execute')) {
         $cronjobExec->execute($this->data);
     }
     // log success.
     CronjobEditor::logSuccess($logID, true);
 }