/** * This tests that queueitems that are marked as regenerating, but are older * than 10 minutes actually gets another try */ public function testDeadEntries() { $oldObject = new StaticPagesQueue(array('URLSegment' => 'old/page', 'Freshness' => 'regenerating')); $oldObject->write(); // Update the entry directly, this is the only way to change LastEdited to a set value DB::query('UPDATE "StaticPagesQueue" SET "LastEdited" =\'' . date("Y-m-d H:i:s", time() - 60 * 11) . '\''); Injector::inst()->get('URLArrayObject')->addUrls(array('monkey/bites' => 1), true); $this->assertEquals('monkey/bites', StaticPagesQueue::get_next_url()); $this->assertEquals('old/page', StaticPagesQueue::get_next_url()); Injector::inst()->get('URLArrayObject')->addUrls(array('should/be/next' => 1), true); $this->assertEquals('should/be/next', StaticPagesQueue::get_next_url()); }
/** * * @return boolean - if this task was run */ protected function buildCache() { $this->updatePid(); $this->load_error_handlers(); $published = 0; while (self::$current_url = StaticPagesQueue::get_next_url()) { $this->updatePid(); $prePublishTime = microtime(true); $results = $this->createCachedFiles(array(self::$current_url)); if ($this->verbose) { foreach ($results as $url => $data) { $this->printPublishingMetrics($published++, $prePublishTime, $url, sprintf('HTTP Status: %d', $results[$url]['statuscode'])); } } $this->logSummary($published, false, $prePublishTime); StaticPagesQueue::delete_by_link(self::$current_url); } if ($published) { $this->logSummary($published, true, $prePublishTime); } return true; }