PortableInfobox/includes/PortableInfoboxHooks.php

83 lines
2.1 KiB
PHP
Raw Normal View History

<?php
2019-12-18 18:00:05 +00:00
use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\RenderedRevision;
2022-03-11 20:35:51 +00:00
use PortableInfobox\Helpers\PortableInfoboxDataBag;
2019-12-18 18:00:05 +00:00
class PortableInfoboxHooks {
2015-06-19 12:16:07 +00:00
public static function onWgQueryPages( array &$queryPages = [] ) {
$queryPages[] = [ 'AllInfoboxesQueryPage', 'AllInfoboxes' ];
return true;
}
public static function onAfterParserFetchFileAndTitle(
Parser $parser, ImageGalleryBase $gallery, string &$html
2018-10-02 07:41:19 +00:00
) {
2022-03-11 20:35:51 +00:00
PortableInfoboxDataBag::getInstance()->setGallery(
// @phan-suppress-next-line PhanDeprecatedProperty
2018-10-02 07:41:19 +00:00
Parser::MARKER_PREFIX . '-gallery-' . sprintf( '%08X', $parser->mMarkerIndex - 1 ) .
Parser::MARKER_SUFFIX,
$gallery
);
return true;
}
public static function onAllInfoboxesQueryRecached() {
2019-12-18 18:00:05 +00:00
$cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
$cache->delete( $cache->makeKey( ApiQueryAllInfoboxes::MCACHE_KEY ) );
return true;
}
/**
* Purge memcache before edit
*
* @param RenderedRevision $renderedRevision
*/
public static function onMultiContentSave( RenderedRevision $renderedRevision ) {
$articleID = $renderedRevision->getRevision()->getPageId();
$title = Title::newFromId( $articleID );
if ( $title ) {
$dataService = PortableInfoboxDataService::newFromTitle( $title );
$dataService->delete();
if ( $title->inNamespace( NS_TEMPLATE ) ) {
$dataService->reparseArticle();
}
}
}
/**
* Purge memcache, this will not rebuild infobox data
*
* @param Page $article
*
* @return bool
*/
SUS-2178: &$this should not be passed by reference (#13444) * SUS-2178: Normalize hook handling in Answers * SUS-2178: Normalize hook handling in Achievements * SUS-2178: Normalize hook handling in AppPromoLanding * SUS-2178: Normalize hook handling in ArticleComments * SUS-2178: Normalize hook handling in ArchiveWikiForum * SUS-2178: Normalize hook handling in ArticleAsJson * SUS-2178: Normalize hook handling in ArticleMetaDescription * SUS-2178: Normalize hook handling in AutoMainpageFixer * SUS-2178: Normalize hook handling AutomaticWikiAdoptionHelper * SUS-2178: Normalize hook handling in BannerNotifications * SUS-2178: Normalize hook handling in Blogs * SUS-2178: Normalize hook handling in CanonicalHref * SUS-2178: Normalize hook handling in Category* * SUS-2178: Normalize hook handling in Chat * SUS-2178: Normalize hook handling in CloseMyAccount * SUS-2178: Normalize hook handling in CommunityMessages * SUS-2178: Normalize hook handling in Comteam * SUS-2178: Normalize hook handling in ContentFeeds * SUS-2178: Normalize hook handling in ContentWarning * SUS-2178: Normalize hook handling in CreatePage * SUS-2178: Normalize hook handling in Discussions * SUS-2178: Normalize hook handling in EditPageLayout * SUS-2178: Normalize hook handling in EditTagging * SUS-2178: Normalize hook handling in EditorPreference * SUS-2178: Normalize hook handling in FlowTracking * SUS-2178: Normalize hook handling in Follow * SUS-2178: Normalize hook handling in Forum * SUS-2178: Normalize hook handling in FounderProgressBar * SUS-2178: Normalize hook handling in HAWelcome * SUS-2178: Normalize hook handling in ImageLazyLoad * SUS-2178: Normalize hook handling in ImageServing * SUS-2178: Normalize hook handling in ImageSizeInfoFunctions * SUS-2178: Normalize hook handling in IndexingPipeline * SUS-2178: Normalize hook handling inInfoboxBuilder * SUS-2178: Normalize hook handling in InterwikiDispatcher * SUS-2178: Normalize hook handling in LatestPhotos * SUS-2178: Normalize hook handling in LinkSuggest * SUS-2178: Normalize hook handling in MainPageTag * SUS-2178: Normalize hook handling in MobileContent * SUS-2178: Normalize hook handling in MyHome * SUS-2178: Normalize hook handling in YouTube * SUS-2178: Normalize hook handling in Phalanx * SUS-2178: Normalize hook handling in Piggyback * SUS-2178: Normalize hook handling in Places * SUS-2178: Normalize hook handling in xbox * SUS-2178: Normalize hook handling in PortableInfobox * SUS-2178: Normalize hook handling in Qualaroo * SUS-2178: Normalize hook handling in RTE * SUS-2178: Normalize hook handling in SEOTweaks * SUS-2178: Normalize hook handling in Scribe * SUS-2178: Normalize hook handling in SharedHelp * SUS-2178: Normalize hook handling in SiteWideMessages * SUS-2178: Normalize hook handling in StaffSig * SUS-2178: Normalize hook handling in UserLogin * SUS-2178: Normalize hook handling in Profile * SUS-2178: Normalize hook handling in Video * SUS-2178: Normalize hook handling in Wall * sus-2178: Normalize hook handling in WAMPage * SUS-2178: Normalize hook Handling in WallNotifications * SUS-2178: Normalize hook handling in WidgetTag * SUS-2178: Normalize hook handling in WikiAnswers * SUS-2178: Normalize hook handling in WikiFactory * SUS-2178: Normalize hook handling in WikiaApi * SUS-2178: Normalize hook handling in WMU * SUS-2178: Normalize hook handling in WikiaMobile * SUS-2178: Normalize hook handling in WikiaPhotoGallery * SUS-2178: Normalize hook handling in WikiaNewtalk * SUS-2178: Normalize hook handling in WikiaWhiteList * SUS-2178: Normalize hook handling in skins * SUS-2178: Normalize hook handling in VisualEditor, remove dead code * SUS-2178: Normalize hooks handling in AbuseFilter * SUS-2178: Normalize hook handling in Variables * SUS-2178: Normalize hooks handling in AntiSpoof * SUS-2178: Normalize hook handling in Arrays * SUS-2178: Normalize hooks handling in Loops * SUS-2178: Normalize hooks handling in Autoincrement * SUS-2178: Normalize hooks handling in CharInsert * SUS-2178: Normalize hooks handling in CharInsert * SUS-2178: Normalize hook handling in ImageMap * SUS-2178: Normalize hooks handling in ConfirmEdit * SUS-2178: Normalize hooks handling in DPLforu * SUS-2178: Normalize hooks handling in Scribunto * SUS-2178: Normalize hooks handling in InputBox * SUS-2178: Normalize hooks handling in MultiUpload * SUS-2178: Normalize hooks handling in OGM * SUS-2178: Normalize hooks handling in Poem * SUS-2178: Normalize hooks handling in RandomImage * SUS-2178: Normalize hooks handling in RegexFu * SUS-2178: Normalize hooks handling in Semantic* * SUS-2178: Normalize hook handling in SpamBlacklist * SUS-2178: Normalize hooks handling in GeSHi * SUS-2178: Normalize hooks handling in TitleBlacklist * SUS-2178: Normalize hooks handling in TorBlock * SUS-2178: Normalize hooks handling in timeline * SUS-2178: Normalize hook handling in includes/wikia * SUS-2178: add few extension hooks I missed * SUS-2178: Get rid of &$this from core MediaWiki * SUS-2178: Remove remaining &$this from extensions * SUS-2178: Remove &$this from maintenance scripts * SUS-2178: remove annoying hooks.txt &$this * SUS-2178: apply SonarQube suggestions * SUS-2178: add two missing extensions * SUS-2178: Update Maps and SMW via composer * SUS-2178: BeforeParserrenderImageGallery - bring back the wonders of pass by reference * Disabling memcache in NavigationTest * SUS-2178: Normalize hook handling in TwitterCards * SUS-2178: Correct parameter type in CommunityMessages * SUS-2178: Correct parameter type in WallHooksHelper::onPersonalUrls * SUS-2178: Correct parameter type in FollowHelper::addPersonalUrl * SUS-2178: Correct parameter type in WikiaApp::onArticleViewHeader * SUS-2178: Correct parameter type in ArticleComment::watchlistNotify * SUS-2178: onArticleSaveComplete - $revision may be null for null edits * SUS-2178: Correct few errors in Scribe and Variables * SUS-2178: Correct parameter types in Arrays extension * SUS-2178: fix class resolution error in IndexingPipeline * SUS-2178: Fix type hint in WallHooksHelper * SUS-2178: Include Maps schema * SUS-2178: Correct parameter types in PageStatsService * SUS-2178: Correct parameter type in ContentReviewHooks::onArticleDeleteComplete * SUS-2178: Update WallHooksHelper::onUserIsBlockedFrom * SUS-2178: Correct parameter type in GadgetHooks::registerModules * SUS-2178: Correct parameter type in FliteTagController * SUS-2178: Correct few more param types * SUS-2178: Remove &$parser from legacy extensions
2017-08-07 19:26:54 +00:00
public static function onArticlePurge( Page $article ) {
PortableInfoboxDataService::newFromTitle( $article->getTitle() )->purge();
return true;
}
public static function onResourceLoaderRegisterModules( ResourceLoader &$resourceLoader ) {
global $wgResourceModules;
2018-10-02 07:41:19 +00:00
if ( isset( $wgResourceModules['ext.templateDataGenerator.data'] ) ) {
$wgResourceModules['ext.templateDataGenerator.data']['scripts'][] =
'../PortableInfobox/resources/PortableInfoboxParams.js';
$resourceLoader->register(
'ext.templateDataGenerator.data',
$wgResourceModules['ext.templateDataGenerator.data']
);
}
return true;
}
}