/**
  * @since 2.1
  *
  * @param mixed $title
  *
  * @return PageRefresher
  */
 public function doRefreshByUpdateJob($title)
 {
     if ($title instanceof WikiPage || $title instanceof DIWikiPage) {
         $title = $title->getTitle();
     }
     if (is_string($title)) {
         $title = Title::newFromText($title);
     }
     if (!$title instanceof Title) {
         throw new RuntimeException('Expected a title instance');
     }
     $job = new UpdateJob($title);
     $job->run();
     return $this;
 }
Example #2
0
 public function testJobWithValidRevision()
 {
     $title = $this->getMockBuilder('Title')->disableOriginalConstructor()->getMock();
     $title->expects($this->once())->method('getDBkey')->will($this->returnValue(__METHOD__));
     $title->expects($this->once())->method('getNamespace')->will($this->returnValue(0));
     $title->expects($this->once())->method('exists')->will($this->returnValue(true));
     $contentParser = $this->getMockBuilder('\\SMW\\ContentParser')->disableOriginalConstructor()->getMock();
     $contentParser->expects($this->atLeastOnce())->method('getOutput')->will($this->returnValue(new \ParserOutput()));
     $this->applicationFactory->registerObject('ContentParser', $contentParser);
     $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->setMethods(array('updateData'))->getMockForAbstractClass();
     $store->expects($this->once())->method('updateData');
     $this->applicationFactory->registerObject('Store', $store);
     $instance = new UpdateJob($title);
     $instance->setJobQueueEnabledState(false);
     $this->assertTrue($instance->run());
 }
Example #3
0
 protected function rebuildSelectedPages()
 {
     $this->reportMessage("Refreshing specified pages!\n" . ($this->verbose ? "\n" : ''));
     $pages = $this->query ? $this->getPagesFromQuery() : array();
     $pages = $this->pages ? array_merge((array) $this->pages, $pages) : $pages;
     $pages = $this->filters ? array_merge($pages, $this->getPagesFromFilters()) : $pages;
     $numPages = count($pages);
     $titleCache = array();
     foreach ($pages as $page) {
         $title = $this->makeTitleOf($page);
         if ($title !== null && !isset($titleCache[$title->getPrefixedDBkey()])) {
             $this->rebuildCount++;
             $percentage = round($this->rebuildCount / $numPages * 100);
             $this->reportMessage("({$this->rebuildCount}/{$numPages} {$percentage}%) Processing page " . $title->getPrefixedDBkey() . " ...\n", $this->verbose);
             $updatejob = new UpdateJob($title);
             $updatejob->run();
             $this->doPrintDotProgressIndicator($this->verbose);
             $titleCache[$title->getPrefixedDBkey()] = true;
         }
     }
     $this->reportMessage("\n{$this->rebuildCount} pages refreshed.\n");
     return true;
 }
 private function doRebuildPagesFor($message)
 {
     $this->reportMessage($message . "\n");
     $pages = $this->getPagesFromQuery();
     $pages = $this->pages ? array_merge((array) $this->pages, $pages) : $pages;
     $pages = $this->hasFilters() ? array_merge($pages, $this->getPagesFromFilters()) : $pages;
     $this->normalizeBulkOfPages($pages);
     $numPages = count($pages);
     foreach ($pages as $page) {
         $this->rebuildCount++;
         $percentage = round($this->rebuildCount / $numPages * 100) . "%";
         $this->reportMessage("({$this->rebuildCount}/{$numPages} {$percentage}) Processing page " . $page->getPrefixedDBkey() . " ...\n", $this->verbose);
         $updatejob = new UpdateJob($page, array('pm' => $this->options->has('shallow-update') ? SMW_UJ_PM_CLASTMDATE : false));
         $updatejob->run();
         $this->doPrintDotProgressIndicator($this->verbose, $percentage);
     }
     $this->reportMessage("\n\n{$this->rebuildCount} pages refreshed.\n");
     return true;
 }
Example #5
0
 /**
  * @see Store::changeTitle()
  * @since 1.6
  */
 public function changeTitle(Title $oldtitle, Title $newtitle, $pageid, $redirid = 0)
 {
     $oldWikiPage = DIWikiPage::newFromTitle($oldtitle);
     $newWikiPage = DIWikiPage::newFromTitle($newtitle);
     $oldExpResource = Exporter::getInstance()->getDataItemExpElement($oldWikiPage);
     $newExpResource = Exporter::getInstance()->getDataItemExpElement($newWikiPage);
     $namespaces = array($oldExpResource->getNamespaceId() => $oldExpResource->getNamespace());
     $namespaces[$newExpResource->getNamespaceId()] = $newExpResource->getNamespace();
     $oldUri = TurtleSerializer::getTurtleNameForExpElement($oldExpResource);
     $newUri = TurtleSerializer::getTurtleNameForExpElement($newExpResource);
     // do this only here, so Imported from is not moved too early
     $this->baseStore->changeTitle($oldtitle, $newtitle, $pageid, $redirid);
     $sparqlDatabase = $this->getConnection();
     $sparqlDatabase->insertDelete("?s ?p {$newUri}", "?s ?p {$oldUri}", "?s ?p {$oldUri}", $namespaces);
     if ($oldtitle->getNamespace() === SMW_NS_PROPERTY) {
         $sparqlDatabase->insertDelete("?s {$newUri} ?o", "?s {$oldUri} ?o", "?s {$oldUri} ?o", $namespaces);
     }
     // Note that we cannot change oldUri to newUri in triple subjects,
     // since some triples change due to the move.
     $newUpdate = new UpdateJob($newtitle);
     $newUpdate->run();
     if ($redirid != 0) {
         // update/create redirect page data
         $oldUpdate = new UpdateJob($oldtitle);
         $oldUpdate->run();
     }
     // #566 $redirid == 0 indicates a `move` not a redirect action
     if ($redirid == 0) {
         $this->doSparqlDataDelete($oldWikiPage);
     }
 }
 public function testJobToCompareLastModified()
 {
     $title = $this->getMockBuilder('Title')->disableOriginalConstructor()->getMock();
     $title->expects($this->atLeastOnce())->method('getDBkey')->will($this->returnValue(__METHOD__));
     $title->expects($this->atLeastOnce())->method('getNamespace')->will($this->returnValue(0));
     $title->expects($this->atLeastOnce())->method('exists')->will($this->returnValue(true));
     $contentParser = $this->getMockBuilder('\\SMW\\ContentParser')->disableOriginalConstructor()->getMock();
     $contentParser->expects($this->atLeastOnce())->method('getOutput')->will($this->returnValue(new \ParserOutput()));
     $this->applicationFactory->registerObject('ContentParser', $contentParser);
     $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->setMethods(array('getPropertyValues', 'getWikiPageLastModifiedTimestamp'))->getMockForAbstractClass();
     $store->expects($this->any())->method('getPropertyValues')->will($this->returnValue(array()));
     $store->expects($this->once())->method('getWikiPageLastModifiedTimestamp')->will($this->returnValue(0));
     $this->applicationFactory->registerObject('Store', $store);
     $instance = new UpdateJob($title, array('pm' => SMW_UJ_PM_CLASTMDATE));
     $instance->setJobQueueEnabledState(false);
     $this->assertTrue($instance->run());
 }
 public function testJobToCompareLastModified()
 {
     $title = $this->getMockBuilder('Title')->disableOriginalConstructor()->getMock();
     $title->expects($this->atLeastOnce())->method('getDBkey')->will($this->returnValue(__METHOD__));
     $title->expects($this->atLeastOnce())->method('getNamespace')->will($this->returnValue(0));
     $title->expects($this->atLeastOnce())->method('exists')->will($this->returnValue(true));
     $contentParser = $this->getMockBuilder('\\SMW\\ContentParser')->disableOriginalConstructor()->getMock();
     $contentParser->expects($this->atLeastOnce())->method('getOutput')->will($this->returnValue(new \ParserOutput()));
     $this->testEnvironment->registerObject('ContentParser', $contentParser);
     $idTable = $this->getMockBuilder('\\stdClass')->setMethods(array('hasIDFor'))->getMock();
     $store = $this->getMockBuilder('\\SMW\\SQLStore\\SQLStore')->disableOriginalConstructor()->setMethods(array('getPropertyValues', 'getObjectIds'))->getMock();
     $store->expects($this->any())->method('getObjectIds')->will($this->returnValue($idTable));
     $store->expects($this->any())->method('getPropertyValues')->will($this->returnValue(array()));
     $this->testEnvironment->registerObject('Store', $store);
     $instance = new UpdateJob($title, array('pm' => SMW_UJ_PM_CLASTMDATE));
     $instance->isEnabledJobQueue(false);
     $this->assertTrue($instance->run());
 }