public function testCanConstructTextByChangeUpdater()
 {
     $connection = $this->getMockBuilder('\\SMW\\MediaWiki\\Database')->disableOriginalConstructor()->getMock();
     $this->store->expects($this->atLeastOnce())->method('getConnection')->will($this->returnValue($connection));
     $instance = new FulltextSearchTableFactory();
     $this->assertInstanceOf('\\SMW\\SQLStore\\QueryEngine\\Fulltext\\TextByChangeUpdater', $instance->newTextByChangeUpdater($this->store));
 }
 /**
  * @see Job::run
  *
  * @since  2.5
  */
 public function run()
 {
     $fulltextSearchTableFactory = new FulltextSearchTableFactory();
     $textByChangeUpdater = $fulltextSearchTableFactory->newTextByChangeUpdater(ApplicationFactory::getInstance()->getStore('\\SMW\\SQLStore\\SQLStore'));
     $textByChangeUpdater->pushUpdatesFromJobParameters($this->params);
     Hooks::run('SMW::Job::AfterSearchTableUpdateComplete', array($this));
     return true;
 }
예제 #3
0
 private function registerHooksForInternalUse(ApplicationFactory $applicationFactory, DeferredRequestDispatchManager $deferredRequestDispatchManager)
 {
     $queryDependencyLinksStoreFactory = new QueryDependencyLinksStoreFactory();
     $queryDependencyLinksStore = $queryDependencyLinksStoreFactory->newQueryDependencyLinksStore($applicationFactory->getStore());
     $transitionalDiffStore = $applicationFactory->singleton('TransitionalDiffStore');
     /**
      * @see https://www.semantic-mediawiki.org/wiki/Hooks#SMW::SQLStore::AfterDataUpdateComplete
      */
     $this->handlers['SMW::SQLStore::AfterDataUpdateComplete'] = function ($store, $semanticData, $compositePropertyTableDiffIterator) use($queryDependencyLinksStoreFactory, $queryDependencyLinksStore, $deferredRequestDispatchManager, $transitionalDiffStore) {
         // When in commandLine mode avoid deferred execution and run a process
         // within the same transaction
         $deferredRequestDispatchManager->isCommandLineMode($store->getOptions()->has('isCommandLineMode') ? $store->getOptions()->get('isCommandLineMode') : $GLOBALS['wgCommandLineMode']);
         $queryDependencyLinksStore->setStore($store);
         $subject = $semanticData->getSubject();
         $slot = $transitionalDiffStore->createSlotFrom($compositePropertyTableDiffIterator);
         $queryDependencyLinksStore->pruneOutdatedTargetLinks($subject, $compositePropertyTableDiffIterator);
         $entityIdListRelevanceDetectionFilter = $queryDependencyLinksStoreFactory->newEntityIdListRelevanceDetectionFilter($store, $compositePropertyTableDiffIterator);
         $jobParameters = $queryDependencyLinksStore->buildParserCachePurgeJobParametersFrom($entityIdListRelevanceDetectionFilter);
         $deferredRequestDispatchManager->scheduleParserCachePurgeJobWith($subject->getTitle(), $jobParameters);
         $fulltextSearchTableFactory = new FulltextSearchTableFactory();
         $textByChangeUpdater = $fulltextSearchTableFactory->newTextByChangeUpdater($store);
         $textByChangeUpdater->pushUpdates($compositePropertyTableDiffIterator, $deferredRequestDispatchManager, $slot);
         // Since we cannot predict as to when the slot is used and by whom,
         // schedule a job to ensure to be the last in-line to clean-up
         // any remaining slots for this transaction
         $deferredRequestDispatchManager->scheduleChronologyPurgeJobWith($subject->getTitle(), array('slot:id' => $slot));
         return true;
     };
     /**
      * @see https://www.semantic-mediawiki.org/wiki/Hooks#SMW::Store::AfterQueryResultLookupComplete
      */
     $this->handlers['SMW::Store::AfterQueryResultLookupComplete'] = function ($store, &$result) use($queryDependencyLinksStore, $applicationFactory) {
         $queryDependencyLinksStore->setStore($store);
         $queryDependencyLinksStore->doUpdateDependenciesFrom($result);
         $applicationFactory->singleton('CachedQueryResultPrefetcher')->recordStats();
         return true;
     };
 }