/**
  * @since 2.2
  *
  * @param Store $store
  * @param Callable|null $reporterCallback
  *
  * @return ConceptCacheRebuilder
  */
 public function newConceptCacheRebuilder(Store $store, $reporterCallback = null)
 {
     $messageReporter = MessageReporterFactory::getInstance()->newObservableMessageReporter();
     $messageReporter->registerReporterCallback($reporterCallback);
     $conceptCacheRebuilder = new ConceptCacheRebuilder($store, ApplicationFactory::getInstance()->getSettings());
     $conceptCacheRebuilder->setMessageReporter($messageReporter);
     return $conceptCacheRebuilder;
 }
 private function acquireInstanceFor($concept = null)
 {
     $expectedToRun = $concept !== null ? $this->any() : $this->never();
     $refreshConceptCacheReturn = $concept !== null ? $concept->getConceptQuery() : null;
     $row = new \stdClass();
     $row->page_namespace = 0;
     $row->page_title = 1;
     $database = $this->getMockBuilder('\\SMW\\MediaWiki\\Database')->disableOriginalConstructor()->getMock();
     $database->expects($expectedToRun)->method('select')->will($this->returnValue(array($row)));
     $store = $this->getMockBuilder('SMWSQLStore3')->disableOriginalConstructor()->getMock();
     $store->expects($this->once())->method('getConceptCacheStatus')->will($this->returnValue($concept));
     $store->expects($expectedToRun)->method('refreshConceptCache')->will($this->returnValue(array($refreshConceptCacheReturn)));
     $store->expects($expectedToRun)->method('getConnection')->will($this->returnValue($database));
     $settings = $this->getMockBuilder('\\SMW\\Settings')->disableOriginalConstructor()->getMock();
     $instance = new ConceptCacheRebuilder($store, $settings);
     $instance->setParameters(array('quiet' => true));
     return $instance;
 }
Exemplo n.º 3
0
 /**
  * @see Maintenance::execute
  */
 public function execute()
 {
     if (!defined('SMW_VERSION')) {
         $this->reportMessage("You need to have SMW enabled in order to run the maintenance script!\n\n");
         return false;
     }
     $applicationFactory = ApplicationFactory::getInstance();
     $reporter = new ObservableMessageReporter();
     $reporter->registerReporterCallback(array($this, 'reportMessage'));
     $conceptCacheRebuilder = new ConceptCacheRebuilder($applicationFactory->getStore(), $applicationFactory->getSettings());
     $conceptCacheRebuilder->setMessageReporter($reporter);
     $conceptCacheRebuilder->setParameters($this->mOptions);
     if ($conceptCacheRebuilder->rebuild()) {
         return true;
     }
     $this->reportMessage($this->mDescription . "\n\n" . 'Use option --help for usage details.' . "\n");
     return false;
 }