/**
  * run the job, then remove it from the joblist
  *
  * @param JobList $jobList
  * @param ILogger $logger
  */
 public function execute($jobList, ILogger $logger = null)
 {
     $jobList->remove($this, $this->argument);
     $target = $this->argument['url'];
     // only execute if target is still in the list of trusted domains
     if ($this->trustedServers->isTrustedServer($target)) {
         $this->parentExecute($jobList, $logger);
     }
 }
Beispiel #2
0
 /**
  * @param JobList $jobList
  * @param ILogger $logger
  */
 public function execute($jobList, ILogger $logger = null)
 {
     $jobList->setLastRun($this);
     try {
         $this->run($this->argument);
     } catch (\Exception $e) {
         if ($logger) {
             $logger->logException($e, ['app' => 'core', 'message' => 'Error while running background job (class: ' . get_class($this) . ', arguments: ' . print_r($this->argument, true) . ')']);
         }
     }
 }
Beispiel #3
0
 /**
  * @param JobList $jobList
  * @param ILogger $logger
  */
 public function execute($jobList, ILogger $logger = null)
 {
     $jobList->setLastRun($this);
     try {
         $this->run($this->argument);
     } catch (\Exception $e) {
         if ($logger) {
             $logger->error('Error while running background job: ' . $e->getMessage());
         }
     }
 }
Beispiel #4
0
 public function testSetLastRun()
 {
     $job = new TestJob();
     $this->instance->add($job);
     $jobs = $this->getAllSorted();
     $addedJob = $jobs[count($jobs) - 1];
     $timeStart = time();
     $this->instance->setLastRun($addedJob);
     $timeEnd = time();
     $addedJob = $this->instance->getById($addedJob->getId());
     $this->assertGreaterThanOrEqual($timeStart, $addedJob->getLastRun());
     $this->assertLessThanOrEqual($timeEnd, $addedJob->getLastRun());
 }
Beispiel #5
0
 public function testGetNextNonExisting()
 {
     $job = new TestJob();
     $this->instance->add($job, 1);
     $this->instance->add('\\OC\\Non\\Existing\\Class');
     $this->instance->add($job, 2);
     $jobs = $this->getAllSorted();
     $savedJob1 = $jobs[count($jobs) - 2];
     $savedJob2 = $jobs[count($jobs) - 1];
     $this->config->expects($this->any())->method('getAppValue')->with('backgroundjob', 'lastjob', 0)->will($this->returnValue($savedJob1->getId()));
     $this->instance->getNext();
     $nextJob = $this->instance->getNext();
     $this->assertEquals($savedJob2, $nextJob);
     $this->instance->remove($job, 1);
     $this->instance->remove($job, 2);
 }
 /**
  * @deprecated
  * deletes a queued task
  * @param int $id id of task
  * @return bool
  *
  * Deletes a report
  */
 public static function deleteQueuedTask($id)
 {
     $jobList = new JobList();
     $job = $jobList->getById($id);
     if ($job) {
         $jobList->remove($job);
     }
 }
Beispiel #7
0
 /**
  * run the job, then remove it from the joblist
  *
  * @param JobList $jobList
  * @param ILogger $logger
  */
 public function execute($jobList, ILogger $logger = null)
 {
     $jobList->remove($this, $this->argument);
     parent::execute($jobList, $logger);
 }