2013-08-26 02:24:36 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An check external links job
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class CheckExternalLinksJob extends AbstractQueuedJob {
|
|
|
|
|
|
|
|
public static $regenerate_time = 43200;
|
|
|
|
|
|
|
|
public function __construct() {
|
2013-08-26 04:52:02 +02:00
|
|
|
$this->pagesToProcess = DB::query('SELECT "ID" FROM "SiteTree_Live" WHERE "ShowInSearch"=1')->column();
|
2013-08-26 02:24:36 +02:00
|
|
|
$this->currentStep = 0;
|
|
|
|
$this->totalSteps = count($this->pagesToProcess);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sitemap job is going to run for a while...
|
|
|
|
*/
|
|
|
|
public function getJobType() {
|
|
|
|
return QueuedJob::QUEUED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getTitle() {
|
|
|
|
return 'Checking external links';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a signature for this queued job
|
|
|
|
*
|
|
|
|
* For the generate sitemap job, we only ever want one instance running, so just use the class name
|
|
|
|
*
|
|
|
|
* @return String
|
|
|
|
*/
|
|
|
|
public function getSignature() {
|
|
|
|
return md5(get_class($this));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Note that this is duplicated for backwards compatibility purposes...
|
|
|
|
*/
|
|
|
|
public function setup() {
|
|
|
|
parent::setup();
|
|
|
|
increase_time_limit_to();
|
|
|
|
|
|
|
|
$restart = $this->currentStep == 0;
|
|
|
|
|
|
|
|
if ($restart) {
|
2013-08-26 04:52:02 +02:00
|
|
|
$this->pagesToProcess = DB::query('SELECT "ID" FROM SiteTree_Live WHERE ShowInSearch=1')->column();
|
2013-08-26 02:24:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* On any restart, make sure to check that our temporary file is being created still.
|
|
|
|
*/
|
|
|
|
public function prepareForRestart() {
|
|
|
|
parent::prepareForRestart();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function process() {
|
2013-08-26 02:53:01 +02:00
|
|
|
$task = new CheckExternalLinks();
|
2013-08-26 02:24:36 +02:00
|
|
|
$task->run();
|
2013-08-26 02:53:01 +02:00
|
|
|
$this->completeJob();
|
2013-08-26 02:24:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Outputs the completed file to the site's webroot
|
|
|
|
*/
|
|
|
|
protected function completeJob() {
|
2013-08-26 02:53:01 +02:00
|
|
|
$this->isComplete = 1;
|
2013-08-26 02:24:36 +02:00
|
|
|
$nextgeneration = new CheckExternalLinksJob();
|
|
|
|
singleton('QueuedJobService')->queueJob($nextgeneration,
|
|
|
|
date('Y-m-d H:i:s', time() + self::$regenerate_time));
|
|
|
|
}
|
|
|
|
}
|