X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fpage%2FWikiPage.php;h=b609d7bd793e7dc9090c444b238dd64f071646e7;hb=a3357744c34d6f5b8e39114e64c6937800698069;hp=a1b2e574d1e8b1aa7b674d70bf93074d60a8f736;hpb=d23c700ef7c58b92869aaf76e82cb801280e36d0;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index a1b2e574d1..b609d7bd79 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -23,6 +23,7 @@ use MediaWiki\Edit\PreparedEdit; use MediaWiki\Logger\LoggerFactory; use MediaWiki\MediaWikiServices; +use MediaWiki\Revision\RevisionRenderer; use MediaWiki\Storage\DerivedPageDataUpdater; use MediaWiki\Storage\PageUpdater; use MediaWiki\Storage\RevisionRecord; @@ -223,6 +224,13 @@ class WikiPage implements Page, IDBAccessObject { return MediaWikiServices::getInstance()->getRevisionStore(); } + /** + * @return RevisionRenderer + */ + private function getRevisionRenderer() { + return MediaWikiServices::getInstance()->getRevisionRenderer(); + } + /** * @return ParserCache */ @@ -931,6 +939,7 @@ class WikiPage implements Page, IDBAccessObject { // links. $hasLinks = (bool)count( $editInfo->output->getLinks() ); } else { + // NOTE: keep in sync with revisionRenderer::getLinkCount $hasLinks = (bool)wfGetDB( DB_REPLICA )->selectField( 'pagelinks', 1, [ 'pl_from' => $this->getId() ], __METHOD__ ); } @@ -1625,15 +1634,16 @@ class WikiPage implements Page, IDBAccessObject { * @return DerivedPageDataUpdater */ private function newDerivedDataUpdater() { - global $wgContLang, $wgRCWatchCategoryMembership, $wgArticleCountMethod; + global $wgRCWatchCategoryMembership, $wgArticleCountMethod; $derivedDataUpdater = new DerivedPageDataUpdater( $this, // NOTE: eventually, PageUpdater should not know about WikiPage $this->getRevisionStore(), + $this->getRevisionRenderer(), $this->getParserCache(), JobQueueGroup::singleton(), MessageCache::singleton(), - $wgContLang, + MediaWikiServices::getInstance()->getContentLanguage(), LoggerFactory::getInstance( 'SaveParse' ) ); @@ -1961,7 +1971,7 @@ class WikiPage implements Page, IDBAccessObject { * Purges pages that include this page if the text was changed here. * Every 100th edit, prune the recent changes table. * - * @deprecated since 1.32, use PageUpdater::doEditUpdates instead. + * @deprecated since 1.32, use PageUpdater::doUpdates instead. * * @param Revision $revision * @param User $user User object that did the revision @@ -2301,14 +2311,13 @@ class WikiPage implements Page, IDBAccessObject { * @return string */ protected function formatExpiry( $expiry ) { - global $wgContLang; - if ( $expiry != 'infinity' ) { + $contLang = MediaWikiServices::getInstance()->getContentLanguage(); return wfMessage( 'protect-expiring', - $wgContLang->timeanddate( $expiry, false, false ), - $wgContLang->date( $expiry, false, false ), - $wgContLang->time( $expiry, false, false ) + $contLang->timeanddate( $expiry, false, false ), + $contLang->date( $expiry, false, false ), + $contLang->time( $expiry, false, false ) )->inContentLanguage()->text(); } else { return wfMessage( 'protect-expiry-indefinite' ) @@ -2366,13 +2375,13 @@ class WikiPage implements Page, IDBAccessObject { * @return string */ public function protectDescriptionLog( array $limit, array $expiry ) { - global $wgContLang; - $protectDescriptionLog = ''; + $dirMark = MediaWikiServices::getInstance()->getContentLanguage()->getDirMark(); foreach ( array_filter( $limit ) as $action => $restrictions ) { $expiryText = $this->formatExpiry( $expiry[$action] ); - $protectDescriptionLog .= $wgContLang->getDirMark() . + $protectDescriptionLog .= + $dirMark . "[$action=$restrictions] ($expiryText)"; } @@ -2841,7 +2850,7 @@ class WikiPage implements Page, IDBAccessObject { public function commitRollback( $fromP, $summary, $bot, &$resultDetails, User $guser, $tags = null ) { - global $wgUseRCPatrol, $wgContLang; + global $wgUseRCPatrol; $dbw = wfGetDB( DB_MASTER ); @@ -2922,13 +2931,14 @@ class WikiPage implements Page, IDBAccessObject { $targetEditorForPublic = $target->getUser( RevisionRecord::FOR_PUBLIC ); // Allow the custom summary to use the same args as the default message + $contLang = MediaWikiServices::getInstance()->getContentLanguage(); $args = [ $targetEditorForPublic ? $targetEditorForPublic->getName() : null, $currentEditorForPublic ? $currentEditorForPublic->getName() : null, $s->rev_id, - $wgContLang->timeanddate( wfTimestamp( TS_MW, $s->rev_timestamp ) ), + $contLang->timeanddate( wfTimestamp( TS_MW, $s->rev_timestamp ) ), $current->getId(), - $wgContLang->timeanddate( $current->getTimestamp() ) + $contLang->timeanddate( $current->getTimestamp() ) ]; if ( $summary instanceof Message ) { $summary = $summary->params( $args )->inContentLanguage()->text(); @@ -3152,6 +3162,9 @@ class WikiPage implements Page, IDBAccessObject { // Image redirects RepoGroup::singleton()->getLocalRepo()->invalidateImageRedirect( $title ); + + // Purge cross-wiki cache entities referencing this page + self::purgeInterwikiCheckKey( $title ); } /** @@ -3190,14 +3203,41 @@ class WikiPage implements Page, IDBAccessObject { // Clear file cache for this page only HTMLFileCache::clearFileCache( $title ); + // Purge ?action=info cache $revid = $revision ? $revision->getId() : null; DeferredUpdates::addCallableUpdate( function () use ( $title, $revid ) { InfoAction::invalidateCache( $title, $revid ); } ); + + // Purge cross-wiki cache entities referencing this page + self::purgeInterwikiCheckKey( $title ); } /**#@-*/ + /** + * Purge the check key for cross-wiki cache entries referencing this page + * + * @param Title $title + */ + private static function purgeInterwikiCheckKey( Title $title ) { + global $wgEnableScaryTranscluding; + + if ( !$wgEnableScaryTranscluding ) { + return; // @todo: perhaps this wiki is only used as a *source* for content? + } + + DeferredUpdates::addCallableUpdate( function () use ( $title ) { + $cache = MediaWikiServices::getInstance()->getMainWANObjectCache(); + $cache->resetCheckKey( + // Do not include the namespace since there can be multiple aliases to it + // due to different namespace text definitions on different wikis. This only + // means that some cache invalidations happen that are not strictly needed. + $cache->makeGlobalKey( 'interwiki-page', wfWikiID(), $title->getDBkey() ) + ); + } ); + } + /** * Returns a list of categories this page is a member of. * Results will include hidden categories @@ -3479,7 +3519,7 @@ class WikiPage implements Page, IDBAccessObject { public function getMutableCacheKeys( WANObjectCache $cache ) { $linkCache = MediaWikiServices::getInstance()->getLinkCache(); - return $linkCache->getMutableCacheKeys( $cache, $this->getTitle()->getTitleValue() ); + return $linkCache->getMutableCacheKeys( $cache, $this->getTitle() ); } }