private function newMockCacheHandler($id, $status)
 {
     $cacheHandler = $this->getMockBuilder('SMW\\Cache\\CacheHandler')->disableOriginalConstructor()->getMock();
     $cacheHandler->expects($this->any())->method('setKey')->with($this->equalTo(ArticlePurge::newCacheId($id)));
     $cacheHandler->expects($this->any())->method('get')->will($this->returnValue($status));
     return $cacheHandler;
 }
예제 #2
0
 /**
  * @note Article purge: In case an article was manually purged/moved
  * the store is updated as well; for all other cases LinksUpdateConstructed
  * will handle the store update
  */
 private function checkForRequestedUpdateByPagePurge($parserData)
 {
     $cache = $this->applicationFactory->getCache();
     $cache->setKey(ArticlePurge::newCacheId($this->parser->getTitle()->getArticleID()));
     if ($cache->get()) {
         $cache->delete();
         $parserData->updateStore();
     }
     return true;
 }
 public function testPagePurge()
 {
     $this->applicationFactory->registerObject('CacheHandler', new \SMW\CacheHandler(new \HashBagOStuff()));
     $this->title = Title::newFromText(__METHOD__);
     $pageCreator = new PageCreator();
     $pageCreator->createPage($this->title)->doEdit('[[Has function hook test::page purge]]');
     $id = ArticlePurge::newCacheId($this->title->getArticleID());
     $pageCreator->getPage()->doPurge();
     $result = ApplicationFactory::getInstance()->getcache()->setKey($id)->get();
     $this->assertTrue($result);
 }
예제 #4
0
 /**
  * @dataProvider titleDataProvider
  */
 public function testProcess($setup, $expected)
 {
     $wikiPage = new WikiPage($setup['title']);
     $pageId = $wikiPage->getTitle()->getArticleID();
     ApplicationFactory::getInstance()->registerObject('Settings', Settings::newFromArray(array('smwgCacheType' => 'hash', 'smwgAutoRefreshOnPurge' => $setup['smwgAutoRefreshOnPurge'], 'smwgFactboxCacheRefreshOnPurge' => $setup['smwgFactboxCacheRefreshOnPurge'])));
     $instance = new ArticlePurge($wikiPage);
     $cache = ApplicationFactory::getInstance()->getCache();
     $id = FactboxCache::newCacheId($pageId);
     //	$cache->setKey( $id )->set( true );
     $this->assertEquals($expected['autorefreshPreProcess'], $cache->setKey($instance->newCacheId($pageId))->get(), 'Asserts the autorefresh cache status before processing');
     // Travis 210.5, 305.3
     $travis = $cache->setKey($id)->get();
     $travisText = json_encode($travis);
     $this->assertEquals($expected['factboxPreProcess'], $travis, "Asserts the factbox cache status before processing, {$travisText}");
     $this->assertFalse($cache->setKey($instance->newCacheId($pageId))->get(), 'Asserts that before processing ...');
     $result = $instance->process();
     // Post-process check
     $this->assertTrue($result, 'Asserts that process() always returns true');
     $this->assertEquals($expected['autorefreshPostProcess'], $cache->setKey($instance->newCacheId($pageId))->get(), 'Asserts the autorefresh cache status after processing');
     $this->assertEquals($expected['factboxPostProcess'], $cache->setCacheEnabled(true)->setKey($id)->get(), 'Asserts the factbox cache status after processing');
 }
 /**
  * @dataProvider titleDataProvider
  */
 public function testProcess($setup, $expected)
 {
     $wikiPage = new WikiPage($setup['title']);
     $pageId = $wikiPage->getTitle()->getArticleID();
     $this->applicationFactory->getSettings()->set('smwgAutoRefreshOnPurge', $setup['smwgAutoRefreshOnPurge']);
     $this->applicationFactory->getSettings()->set('smwgFactboxCacheRefreshOnPurge', $setup['smwgFactboxCacheRefreshOnPurge']);
     $instance = new ArticlePurge();
     $cacheFactory = $this->applicationFactory->newCacheFactory();
     $factboxCacheKey = $cacheFactory->getFactboxCacheKey($pageId);
     $purgeCacheKey = $cacheFactory->getPurgeCacheKey($pageId);
     $this->assertEquals($expected['autorefreshPreProcess'], $this->cache->fetch($purgeCacheKey), 'Asserts the autorefresh cache status before processing');
     // Travis 210.5, 305.3
     $travis = $this->cache->fetch($factboxCacheKey);
     $travisText = json_encode($travis);
     $this->assertEquals($expected['factboxPreProcess'], $travis, "Asserts the factbox cache status before processing, {$travisText}");
     $this->assertFalse($this->cache->fetch($purgeCacheKey), 'Asserts that before processing ...');
     $result = $instance->process($wikiPage);
     // Post-process check
     $this->assertTrue($result);
     $this->assertEquals($expected['autorefreshPostProcess'], $this->cache->fetch($purgeCacheKey), 'Asserts the autorefresh cache status after processing');
     $this->assertEquals($expected['factboxPostProcess'], $this->cache->fetch($factboxCacheKey), 'Asserts the factbox cache status after processing');
 }
예제 #6
0
 /**
  * @since 1.9
  *
  * @return true
  */
 public function process()
 {
     /**
      * @var Settings $settings
      */
     $settings = ApplicationFactory::getInstance()->getSettings();
     /**
      * @var CacheHandler $cache
      */
     $cache = ApplicationFactory::getInstance()->getCache();
     $cache->setCacheEnabled($this->newId > 0)->setKey(ArticlePurge::newCacheId($this->newId))->set($settings->get('smwgAutoRefreshOnPageMove'));
     $cache->setCacheEnabled($this->oldId > 0)->setKey(ArticlePurge::newCacheId($this->oldId))->set($settings->get('smwgAutoRefreshOnPageMove'));
     ApplicationFactory::getInstance()->getStore()->changeTitle($this->oldTitle, $this->newTitle, $this->oldId, $this->newId);
     return true;
 }
예제 #7
0
 /**
  * @since 1.9
  *
  * @return true
  */
 public function process()
 {
     /**
      * @var Settings $settings
      */
     $settings = $this->applicationFactory->getSettings();
     $cache = $this->applicationFactory->newCacheFactory()->newMediaWikiCompositeCache();
     // Delete all data for a non-enabled target NS
     if (!$this->applicationFactory->getNamespaceExaminer()->isSemanticEnabled($this->newTitle->getNamespace())) {
         $cache->delete(FactboxCache::newCacheId($this->oldId)->generateId());
         $this->applicationFactory->getStore()->deleteSubject($this->oldTitle);
     } else {
         $cache->save(ArticlePurge::newCacheId($this->newId)->generateId(), $settings->get('smwgAutoRefreshOnPageMove'));
         $cache->save(ArticlePurge::newCacheId($this->oldId)->generateId(), $settings->get('smwgAutoRefreshOnPageMove'));
         $this->applicationFactory->getStore()->changeTitle($this->oldTitle, $this->newTitle, $this->oldId, $this->newId);
     }
     return true;
 }
예제 #8
0
 private function addCallbackHandlers($basePath, $globalVars)
 {
     $applicationFactory = ApplicationFactory::getInstance();
     $httpRequestFactory = new HttpRequestFactory();
     $deferredRequestDispatchManager = new DeferredRequestDispatchManager($httpRequestFactory->newSocketRequest());
     $deferredRequestDispatchManager->isEnabledHttpDeferredRequest($applicationFactory->getSettings()->get('smwgEnabledHttpDeferredJobRequest'));
     // SQLite has no lock manager making table lock contention very common
     // hence use the JobQueue to enqueue any change request and avoid
     // a rollback due to canceled DB transactions
     $deferredRequestDispatchManager->isPreferredWithJobQueue($GLOBALS['wgDBtype'] === 'sqlite');
     $permissionPthValidator = new PermissionPthValidator();
     /**
      * Hook: ParserAfterTidy to add some final processing to the fully-rendered page output
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/ParserAfterTidy
      */
     $this->handlers['ParserAfterTidy'] = function (&$parser, &$text) {
         $parserAfterTidy = new ParserAfterTidy($parser, $text);
         return $parserAfterTidy->process();
     };
     /**
      * Hook: Called by BaseTemplate when building the toolbox array and
      * returning it for the skin to output.
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/BaseTemplateToolbox
      */
     $this->handlers['BaseTemplateToolbox'] = function ($skinTemplate, &$toolbox) {
         $baseTemplateToolbox = new BaseTemplateToolbox($skinTemplate, $toolbox);
         return $baseTemplateToolbox->process();
     };
     /**
      * Hook: Allows extensions to add text after the page content and article
      * metadata.
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/SkinAfterContent
      */
     $this->handlers['SkinAfterContent'] = function (&$data, $skin = null) {
         $skinAfterContent = new SkinAfterContent($skin);
         return $skinAfterContent->performUpdate($data);
     };
     /**
      * Hook: Called after parse, before the HTML is added to the output
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/OutputPageParserOutput
      */
     $this->handlers['OutputPageParserOutput'] = function (&$outputPage, $parserOutput) {
         $outputPageParserOutput = new OutputPageParserOutput($outputPage, $parserOutput);
         return $outputPageParserOutput->process();
     };
     /**
      * Hook: Add changes to the output page, e.g. adding of CSS or JavaScript
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/BeforePageDisplay
      */
     $this->handlers['BeforePageDisplay'] = function (&$outputPage, &$skin) {
         $beforePageDisplay = new BeforePageDisplay($outputPage, $skin);
         return $beforePageDisplay->process();
     };
     /**
      * Hook: InternalParseBeforeLinks is used to process the expanded wiki
      * code after <nowiki>, HTML-comments, and templates have been treated.
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/InternalParseBeforeLinks
      */
     $this->handlers['InternalParseBeforeLinks'] = function (&$parser, &$text) {
         $internalParseBeforeLinks = new InternalParseBeforeLinks($parser, $text);
         return $internalParseBeforeLinks->process();
     };
     /**
      * Hook: NewRevisionFromEditComplete called when a revision was inserted
      * due to an edit
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/NewRevisionFromEditComplete
      */
     $this->handlers['NewRevisionFromEditComplete'] = function ($wikiPage, $revision, $baseId, $user) {
         $newRevisionFromEditComplete = new NewRevisionFromEditComplete($wikiPage, $revision, $baseId, $user);
         return $newRevisionFromEditComplete->process();
     };
     /**
      * Hook: TitleMoveComplete occurs whenever a request to move an article
      * is completed
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/TitleMoveComplete
      */
     $this->handlers['TitleMoveComplete'] = function ($oldTitle, $newTitle, $user, $oldId, $newId) {
         $titleMoveComplete = new TitleMoveComplete($oldTitle, $newTitle, $user, $oldId, $newId);
         return $titleMoveComplete->process();
     };
     /**
      * Hook: ArticlePurge executes before running "&action=purge"
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/ArticlePurge
      */
     $this->handlers['ArticlePurge'] = function (&$wikiPage) {
         $articlePurge = new ArticlePurge();
         return $articlePurge->process($wikiPage);
     };
     /**
      * Hook: ArticleDelete occurs whenever the software receives a request
      * to delete an article
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/ArticleDelete
      */
     $this->handlers['ArticleDelete'] = function (&$wikiPage, &$user, &$reason, &$error) {
         $articleDelete = new ArticleDelete($wikiPage, $user, $reason, $error);
         return $articleDelete->process();
     };
     /**
      * Hook: LinksUpdateConstructed called at the end of LinksUpdate() construction
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/LinksUpdateConstructed
      */
     $this->handlers['LinksUpdateConstructed'] = function ($linksUpdate) {
         $linksUpdateConstructed = new LinksUpdateConstructed($linksUpdate);
         return $linksUpdateConstructed->process();
     };
     /**
      * Hook: Add extra statistic at the end of Special:Statistics
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/SpecialStatsAddExtra
      */
     $this->handlers['SpecialStatsAddExtra'] = function (&$extraStats) use($globalVars) {
         $specialStatsAddExtra = new SpecialStatsAddExtra($extraStats, $globalVars['wgVersion'], $globalVars['wgLang']);
         return $specialStatsAddExtra->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/FileUpload
      *
      * @since 1.9.1
      */
     $this->handlers['FileUpload'] = function ($file, $reupload) {
         $fileUpload = new FileUpload($file, $reupload);
         return $fileUpload->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderGetConfigVars
      */
     $this->handlers['ResourceLoaderGetConfigVars'] = function (&$vars) {
         $resourceLoaderGetConfigVars = new ResourceLoaderGetConfigVars($vars);
         return $resourceLoaderGetConfigVars->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/GetPreferences
      */
     $this->handlers['GetPreferences'] = function ($user, &$preferences) {
         $getPreferences = new GetPreferences($user, $preferences);
         return $getPreferences->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/SkinTemplateNavigation
      */
     $this->handlers['SkinTemplateNavigation'] = function (&$skinTemplate, &$links) {
         $skinTemplateNavigation = new SkinTemplateNavigation($skinTemplate, $links);
         return $skinTemplateNavigation->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/LoadExtensionSchemaUpdates
      */
     $this->handlers['LoadExtensionSchemaUpdates'] = function ($databaseUpdater) {
         $extensionSchemaUpdates = new ExtensionSchemaUpdates($databaseUpdater);
         return $extensionSchemaUpdates->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderTestModules
      */
     $this->handlers['ResourceLoaderTestModules'] = function (&$testModules, &$resourceLoader) use($basePath, $globalVars) {
         $resourceLoaderTestModules = new ResourceLoaderTestModules($resourceLoader, $testModules, $basePath, $globalVars['IP']);
         return $resourceLoaderTestModules->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/ExtensionTypes
      */
     $this->handlers['ExtensionTypes'] = function (&$extTypes) {
         $extensionTypes = new ExtensionTypes($extTypes);
         return $extensionTypes->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/TitleIsAlwaysKnown
      */
     $this->handlers['TitleIsAlwaysKnown'] = function ($title, &$result) {
         $titleIsAlwaysKnown = new TitleIsAlwaysKnown($title, $result);
         return $titleIsAlwaysKnown->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/BeforeDisplayNoArticleText
      */
     $this->handlers['BeforeDisplayNoArticleText'] = function ($article) {
         $beforeDisplayNoArticleText = new BeforeDisplayNoArticleText($article);
         return $beforeDisplayNoArticleText->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/ArticleFromTitle
      */
     $this->handlers['ArticleFromTitle'] = function (&$title, &$article) {
         $articleFromTitle = new ArticleFromTitle($title, $article);
         return $articleFromTitle->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/TitleIsMovable
      */
     $this->handlers['TitleIsMovable'] = function ($title, &$isMovable) {
         $titleIsMovable = new TitleIsMovable($title, $isMovable);
         return $titleIsMovable->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/EditPage::showEditForm:initial
      */
     $this->handlers['EditPage::showEditForm:initial'] = function ($editPage, $output = null) use($applicationFactory) {
         // 1.19 hook interface is missing the output object
         if (!$output instanceof \OutputPage) {
             $output = $GLOBALS['wgOut'];
         }
         $htmlFormRenderer = $applicationFactory->newMwCollaboratorFactory()->newHtmlFormRenderer($editPage->getTitle(), $output->getLanguage());
         $editPageForm = new EditPageForm($editPage, $htmlFormRenderer);
         return $editPageForm->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/userCan
      */
     $this->handlers['userCan'] = function (&$title, &$user, $action, &$result) use($permissionPthValidator) {
         return $permissionPthValidator->checkUserCanPermissionFor($title, $user, $action, $result);
     };
     $this->registerHooksForInternalUse($applicationFactory, $deferredRequestDispatchManager);
     $this->registerParserFunctionHooks($applicationFactory);
 }
예제 #9
0
 private function addCallbackHandlers($basePath, $globalVars)
 {
     $eventHandler = EventHandler::getInstance();
     $applicationFactory = ApplicationFactory::getInstance();
     $propertyHierarchyLookup = new PropertyHierarchyLookup($applicationFactory->getStore(), $applicationFactory->newCacheFactory()->newFixedInMemoryCache(500));
     $propertyHierarchyLookup->setSubcategoryDepth($applicationFactory->getSettings()->get('smwgQSubcategoryDepth'));
     $propertyHierarchyLookup->setSubpropertyDepth($applicationFactory->getSettings()->get('smwgQSubpropertyDepth'));
     /**
      * Hook: ParserAfterTidy to add some final processing to the fully-rendered page output
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/ParserAfterTidy
      */
     $this->handlers['ParserAfterTidy'] = function (&$parser, &$text) {
         $parserAfterTidy = new ParserAfterTidy($parser, $text);
         return $parserAfterTidy->process();
     };
     /**
      * Hook: Called by BaseTemplate when building the toolbox array and
      * returning it for the skin to output.
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/BaseTemplateToolbox
      */
     $this->handlers['BaseTemplateToolbox'] = function ($skinTemplate, &$toolbox) {
         $baseTemplateToolbox = new BaseTemplateToolbox($skinTemplate, $toolbox);
         return $baseTemplateToolbox->process();
     };
     /**
      * Hook: Allows extensions to add text after the page content and article
      * metadata.
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/SkinAfterContent
      */
     $this->handlers['SkinAfterContent'] = function (&$data, $skin = null) {
         $skinAfterContent = new SkinAfterContent($data, $skin);
         return $skinAfterContent->process();
     };
     /**
      * Hook: Called after parse, before the HTML is added to the output
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/OutputPageParserOutput
      */
     $this->handlers['OutputPageParserOutput'] = function (&$outputPage, $parserOutput) {
         $outputPageParserOutput = new OutputPageParserOutput($outputPage, $parserOutput);
         return $outputPageParserOutput->process();
     };
     /**
      * Hook: Add changes to the output page, e.g. adding of CSS or JavaScript
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/BeforePageDisplay
      */
     $this->handlers['BeforePageDisplay'] = function (&$outputPage, &$skin) {
         $beforePageDisplay = new BeforePageDisplay($outputPage, $skin);
         return $beforePageDisplay->process();
     };
     /**
      * Hook: InternalParseBeforeLinks is used to process the expanded wiki
      * code after <nowiki>, HTML-comments, and templates have been treated.
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/InternalParseBeforeLinks
      */
     $this->handlers['InternalParseBeforeLinks'] = function (&$parser, &$text) {
         $internalParseBeforeLinks = new InternalParseBeforeLinks($parser, $text);
         return $internalParseBeforeLinks->process();
     };
     /**
      * Hook: NewRevisionFromEditComplete called when a revision was inserted
      * due to an edit
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/NewRevisionFromEditComplete
      */
     $this->handlers['NewRevisionFromEditComplete'] = function ($wikiPage, $revision, $baseId, $user) {
         $newRevisionFromEditComplete = new NewRevisionFromEditComplete($wikiPage, $revision, $baseId, $user);
         return $newRevisionFromEditComplete->process();
     };
     /**
      * Hook: TitleMoveComplete occurs whenever a request to move an article
      * is completed
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/TitleMoveComplete
      */
     $this->handlers['TitleMoveComplete'] = function (&$oldTitle, &$newTitle, &$user, $oldId, $newId) {
         $titleMoveComplete = new TitleMoveComplete($oldTitle, $newTitle, $user, $oldId, $newId);
         return $titleMoveComplete->process();
     };
     /**
      * Hook: ArticlePurge executes before running "&action=purge"
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/ArticlePurge
      */
     $this->handlers['ArticlePurge'] = function (&$wikiPage) {
         $articlePurge = new ArticlePurge();
         return $articlePurge->process($wikiPage);
     };
     /**
      * Hook: ArticleDelete occurs whenever the software receives a request
      * to delete an article
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/ArticleDelete
      */
     $this->handlers['ArticleDelete'] = function (&$wikiPage, &$user, &$reason, &$error) {
         $articleDelete = new ArticleDelete($wikiPage, $user, $reason, $error);
         return $articleDelete->process();
     };
     /**
      * Hook: LinksUpdateConstructed called at the end of LinksUpdate() construction
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/LinksUpdateConstructed
      */
     $this->handlers['LinksUpdateConstructed'] = function ($linksUpdate) {
         $linksUpdateConstructed = new LinksUpdateConstructed($linksUpdate);
         return $linksUpdateConstructed->process();
     };
     /**
      * Hook: Add extra statistic at the end of Special:Statistics
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/SpecialStatsAddExtra
      */
     $this->handlers['SpecialStatsAddExtra'] = function (&$extraStats) use($globalVars) {
         $specialStatsAddExtra = new SpecialStatsAddExtra($extraStats, $globalVars['wgVersion'], $globalVars['wgLang']);
         return $specialStatsAddExtra->process();
     };
     /**
      * Hook: For extensions adding their own namespaces or altering the defaults
      *
      * @Bug 34383
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/CanonicalNamespaces
      */
     $this->handlers['CanonicalNamespaces'] = function (&$list) {
         $list = $list + NamespaceManager::getCanonicalNames();
         return true;
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/FileUpload
      *
      * @since 1.9.1
      */
     $this->handlers['FileUpload'] = function ($file, $reupload) {
         $fileUpload = new FileUpload($file, $reupload);
         return $fileUpload->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderGetConfigVars
      */
     $this->handlers['ResourceLoaderGetConfigVars'] = function (&$vars) {
         $resourceLoaderGetConfigVars = new ResourceLoaderGetConfigVars($vars);
         return $resourceLoaderGetConfigVars->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/GetPreferences
      */
     $this->handlers['GetPreferences'] = function ($user, &$preferences) {
         $getPreferences = new GetPreferences($user, $preferences);
         return $getPreferences->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/SkinTemplateNavigation
      */
     $this->handlers['SkinTemplateNavigation'] = function (&$skinTemplate, &$links) {
         $skinTemplateNavigation = new SkinTemplateNavigation($skinTemplate, $links);
         return $skinTemplateNavigation->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/LoadExtensionSchemaUpdates
      */
     $this->handlers['LoadExtensionSchemaUpdates'] = function ($databaseUpdater) {
         $extensionSchemaUpdates = new ExtensionSchemaUpdates($databaseUpdater);
         return $extensionSchemaUpdates->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderTestModules
      */
     $this->handlers['ResourceLoaderTestModules'] = function (&$testModules, &$resourceLoader) use($basePath, $globalVars) {
         $resourceLoaderTestModules = new ResourceLoaderTestModules($resourceLoader, $testModules, $basePath, $globalVars['IP']);
         return $resourceLoaderTestModules->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/ExtensionTypes
      */
     $this->handlers['ExtensionTypes'] = function (&$extTypes) {
         $extensionTypes = new ExtensionTypes($extTypes);
         return $extensionTypes->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/TitleIsAlwaysKnown
      */
     $this->handlers['TitleIsAlwaysKnown'] = function ($title, &$result) {
         $titleIsAlwaysKnown = new TitleIsAlwaysKnown($title, $result);
         return $titleIsAlwaysKnown->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/BeforeDisplayNoArticleText
      */
     $this->handlers['BeforeDisplayNoArticleText'] = function ($article) {
         $beforeDisplayNoArticleText = new BeforeDisplayNoArticleText($article);
         return $beforeDisplayNoArticleText->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/ArticleFromTitle
      */
     $this->handlers['ArticleFromTitle'] = function (&$title, &$article) {
         $articleFromTitle = new ArticleFromTitle($title, $article);
         return $articleFromTitle->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/TitleIsMovable
      */
     $this->handlers['TitleIsMovable'] = function ($title, &$isMovable) {
         $titleIsMovable = new TitleIsMovable($title, $isMovable);
         return $titleIsMovable->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/EditPage::showEditForm:initial
      */
     $this->handlers['EditPage::showEditForm:initial'] = function ($editPage, $output = null) use($applicationFactory) {
         // 1.19 hook interface is missing the output object
         if (!$output instanceof \OutputPage) {
             $output = $GLOBALS['wgOut'];
         }
         $htmlFormRenderer = $applicationFactory->newMwCollaboratorFactory()->newHtmlFormRenderer($editPage->getTitle(), $output->getLanguage());
         $editPageForm = new EditPageForm($editPage, $htmlFormRenderer);
         return $editPageForm->process();
     };
     $this->handlers['SMW::Store::dropTables'] = function ($verbose) use($eventHandler) {
         $eventHandler->getEventDispatcher()->dispatch('blobstore.drop');
         return true;
     };
     $this->handlers['SMW::SQLStore::AfterDataUpdateComplete'] = function ($store, $semanticData, $compositePropertyTableDiffIterator) use($applicationFactory) {
         $embeddedQueryDependencyLinksStore = new EmbeddedQueryDependencyLinksStore($store);
         $embeddedQueryDependencyLinksStore->setEnabledState($applicationFactory->getSettings()->get('smwgEnabledQueryDependencyLinksStore'));
         $embeddedQueryDependencyLinksStore->pruneOutdatedTargetLinks($compositePropertyTableDiffIterator);
         $httpRequestFactory = new HttpRequestFactory();
         $deferredRequestDispatchManager = new DeferredRequestDispatchManager($httpRequestFactory->newSocketRequest());
         $deferredRequestDispatchManager->setEnabledHttpDeferredJobRequestState($applicationFactory->getSettings()->get('smwgEnabledHttpDeferredJobRequest'));
         $deferredRequestDispatchManager->dispatchJobRequestFor('SMW\\ParserCachePurgeJob', $semanticData->getSubject()->getTitle(), $embeddedQueryDependencyLinksStore->buildParserCachePurgeJobParametersFrom($compositePropertyTableDiffIterator));
         return true;
     };
     $this->handlers['SMW::Store::AfterQueryResultLookupComplete'] = function ($store, &$result) use($applicationFactory, $propertyHierarchyLookup) {
         $embeddedQueryDependencyListResolver = new EmbeddedQueryDependencyListResolver($store, $propertyHierarchyLookup);
         $embeddedQueryDependencyListResolver->setQueryResult($result);
         $embeddedQueryDependencyListResolver->setPropertyDependencyDetectionBlacklist($applicationFactory->getSettings()->get('smwgPropertyDependencyDetectionBlacklist'));
         $embeddedQueryDependencyLinksStore = new EmbeddedQueryDependencyLinksStore($store);
         $embeddedQueryDependencyLinksStore->setEnabledState($applicationFactory->getSettings()->get('smwgEnabledQueryDependencyLinksStore'));
         $embeddedQueryDependencyLinksStore->addDependencyList($embeddedQueryDependencyListResolver);
         return true;
     };
     $this->registerParserFunctionHooks($applicationFactory);
 }
예제 #10
0
 private function getListOfFunctionHookDefinitions()
 {
     $functionHookDefinition = array();
     $globalVars = $this->globalVars;
     $basePath = $this->directory;
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/ParserFirstCallInit
      */
     $listOfParserFunctions = $this->getListOfParserFunctionDefinitions();
     $functionHookDefinition['ParserFirstCallInit'] = function (Parser &$parser) use($listOfParserFunctions) {
         foreach ($listOfParserFunctions as $parserFunctionName => $parserDefinition) {
             $parserflag = $parserFunctionName === 'declare' ? SFH_OBJECT_ARGS : 0;
             $parser->setFunctionHook($parserFunctionName, $parserDefinition, $parserflag);
         }
         return true;
     };
     /**
      * Hook: ParserAfterTidy to add some final processing to the fully-rendered page output
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/ParserAfterTidy
      */
     $functionHookDefinition['ParserAfterTidy'] = function (&$parser, &$text) {
         $parserAfterTidy = new ParserAfterTidy($parser, $text);
         return $parserAfterTidy->process();
     };
     /**
      * Hook: Called by BaseTemplate when building the toolbox array and
      * returning it for the skin to output.
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/BaseTemplateToolbox
      */
     $functionHookDefinition['BaseTemplateToolbox'] = function ($skinTemplate, &$toolbox) {
         $baseTemplateToolbox = new BaseTemplateToolbox($skinTemplate, $toolbox);
         return $baseTemplateToolbox->process();
     };
     /**
      * Hook: Allows extensions to add text after the page content and article
      * metadata.
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/SkinAfterContent
      */
     $functionHookDefinition['SkinAfterContent'] = function (&$data, $skin = null) {
         $skinAfterContent = new SkinAfterContent($data, $skin);
         return $skinAfterContent->process();
     };
     /**
      * Hook: Called after parse, before the HTML is added to the output
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/OutputPageParserOutput
      */
     $functionHookDefinition['OutputPageParserOutput'] = function (&$outputPage, $parserOutput) {
         $outputPageParserOutput = new OutputPageParserOutput($outputPage, $parserOutput);
         return $outputPageParserOutput->process();
     };
     /**
      * Hook: Add changes to the output page, e.g. adding of CSS or JavaScript
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/BeforePageDisplay
      */
     $functionHookDefinition['BeforePageDisplay'] = function (&$outputPage, &$skin) {
         $beforePageDisplay = new BeforePageDisplay($outputPage, $skin);
         return $beforePageDisplay->process();
     };
     /**
      * Hook: InternalParseBeforeLinks is used to process the expanded wiki
      * code after <nowiki>, HTML-comments, and templates have been treated.
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/InternalParseBeforeLinks
      */
     $functionHookDefinition['InternalParseBeforeLinks'] = function (&$parser, &$text) {
         $internalParseBeforeLinks = new InternalParseBeforeLinks($parser, $text);
         return $internalParseBeforeLinks->process();
     };
     /**
      * Hook: NewRevisionFromEditComplete called when a revision was inserted
      * due to an edit
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/NewRevisionFromEditComplete
      */
     $functionHookDefinition['NewRevisionFromEditComplete'] = function ($wikiPage, $revision, $baseId, $user) {
         $newRevisionFromEditComplete = new NewRevisionFromEditComplete($wikiPage, $revision, $baseId, $user);
         return $newRevisionFromEditComplete->process();
     };
     /**
      * Hook: TitleMoveComplete occurs whenever a request to move an article
      * is completed
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/TitleMoveComplete
      */
     $functionHookDefinition['TitleMoveComplete'] = function (&$oldTitle, &$newTitle, &$user, $oldId, $newId) {
         $titleMoveComplete = new TitleMoveComplete($oldTitle, $newTitle, $user, $oldId, $newId);
         return $titleMoveComplete->process();
     };
     /**
      * Hook: ArticlePurge executes before running "&action=purge"
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/ArticlePurge
      */
     $functionHookDefinition['ArticlePurge'] = function (&$wikiPage) {
         $articlePurge = new ArticlePurge($wikiPage);
         return $articlePurge->process();
     };
     /**
      * Hook: ArticleDelete occurs whenever the software receives a request
      * to delete an article
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/ArticleDelete
      */
     $functionHookDefinition['ArticleDelete'] = function (&$wikiPage, &$user, &$reason, &$error) {
         $articleDelete = new ArticleDelete($wikiPage, $user, $reason, $error);
         return $articleDelete->process();
     };
     /**
      * Hook: LinksUpdateConstructed called at the end of LinksUpdate() construction
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/LinksUpdateConstructed
      */
     $functionHookDefinition['LinksUpdateConstructed'] = function ($linksUpdate) {
         $linksUpdateConstructed = new LinksUpdateConstructed($linksUpdate);
         return $linksUpdateConstructed->process();
     };
     /**
      * Hook: Add extra statistic at the end of Special:Statistics
      *
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/SpecialStatsAddExtra
      */
     $functionHookDefinition['SpecialStatsAddExtra'] = function (&$extraStats) use($globalVars) {
         $specialStatsAddExtra = new SpecialStatsAddExtra($extraStats, $globalVars['wgVersion'], $globalVars['wgLang']);
         return $specialStatsAddExtra->process();
     };
     /**
      * Hook: For extensions adding their own namespaces or altering the defaults
      *
      * @Bug 34383
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/CanonicalNamespaces
      */
     $functionHookDefinition['CanonicalNamespaces'] = function (&$list) {
         $list = $list + NamespaceManager::getCanonicalNames();
         return true;
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/FileUpload
      *
      * @since 1.9.1
      */
     $functionHookDefinition['FileUpload'] = function ($file, $reupload) {
         $fileUpload = new FileUpload($file, $reupload);
         return $fileUpload->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderGetConfigVars
      */
     $functionHookDefinition['ResourceLoaderGetConfigVars'] = function (&$vars) {
         $resourceLoaderGetConfigVars = new ResourceLoaderGetConfigVars($vars);
         return $resourceLoaderGetConfigVars->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/GetPreferences
      */
     $functionHookDefinition['GetPreferences'] = function ($user, &$preferences) {
         $getPreferences = new GetPreferences($user, $preferences);
         return $getPreferences->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/SkinTemplateNavigation
      */
     $functionHookDefinition['SkinTemplateNavigation'] = function (&$skinTemplate, &$links) {
         $skinTemplateNavigation = new SkinTemplateNavigation($skinTemplate, $links);
         return $skinTemplateNavigation->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/LoadExtensionSchemaUpdates
      */
     $functionHookDefinition['LoadExtensionSchemaUpdates'] = function ($databaseUpdater) {
         $extensionSchemaUpdates = new ExtensionSchemaUpdates($databaseUpdater);
         return $extensionSchemaUpdates->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderTestModules
      */
     $functionHookDefinition['ResourceLoaderTestModules'] = function (&$testModules, &$resourceLoader) use($basePath, $globalVars) {
         $installPath = $globalVars['IP'];
         $resourceLoaderTestModules = new ResourceLoaderTestModules($resourceLoader, $testModules, $basePath, $installPath);
         return $resourceLoaderTestModules->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/ExtensionTypes
      */
     $functionHookDefinition['ExtensionTypes'] = function (&$extTypes) {
         $extensionTypes = new ExtensionTypes($extTypes);
         return $extensionTypes->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/TitleIsAlwaysKnown
      */
     $functionHookDefinition['TitleIsAlwaysKnown'] = function ($title, &$result) {
         $titleIsAlwaysKnown = new TitleIsAlwaysKnown($title, $result);
         return $titleIsAlwaysKnown->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/BeforeDisplayNoArticleText
      */
     $functionHookDefinition['BeforeDisplayNoArticleText'] = function ($article) {
         $beforeDisplayNoArticleText = new BeforeDisplayNoArticleText($article);
         return $beforeDisplayNoArticleText->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/ArticleFromTitle
      */
     $functionHookDefinition['ArticleFromTitle'] = function (&$title, &$article) {
         $articleFromTitle = new ArticleFromTitle($title, $article);
         return $articleFromTitle->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/TitleIsMovable
      */
     $functionHookDefinition['TitleIsMovable'] = function ($title, &$isMovable) {
         $titleIsMovable = new TitleIsMovable($title, $isMovable);
         return $titleIsMovable->process();
     };
     /**
      * @see https://www.mediawiki.org/wiki/Manual:Hooks/EditPage::showEditForm:initial
      */
     $functionHookDefinition['EditPage::showEditForm:initial'] = function ($editPage, $output) {
         $mwCollaboratorFactory = ApplicationFactory::getInstance()->newMwCollaboratorFactory();
         $htmlFormRenderer = $mwCollaboratorFactory->newHtmlFormRenderer($editPage->getTitle(), $output->getLanguage());
         $editPageForm = new EditPageForm($editPage, $htmlFormRenderer);
         return $editPageForm->process();
     };
     return $functionHookDefinition;
 }