X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fresourceloader%2FResourceLoaderWikiModule.php;h=b699b366d1fbe39fe01b12882de476fa45414a1c;hb=a38af7ba26579bb3004f673e44d39710887763aa;hp=ff5de0d9717e264e26dc5f48d2f99315db728121;hpb=2dd32981a8326a6207ac866b39410f1b86179288;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/resourceloader/ResourceLoaderWikiModule.php b/includes/resourceloader/ResourceLoaderWikiModule.php index ff5de0d971..9fad3487f2 100644 --- a/includes/resourceloader/ResourceLoaderWikiModule.php +++ b/includes/resourceloader/ResourceLoaderWikiModule.php @@ -23,8 +23,10 @@ */ use MediaWiki\Linker\LinkTarget; +use Wikimedia\Assert\Assert; use Wikimedia\Rdbms\Database; use Wikimedia\Rdbms\IDatabase; +use MediaWiki\MediaWikiServices; /** * Abstraction for ResourceLoader modules which pull from wiki pages @@ -76,7 +78,8 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule { protected $group; /** - * @param array $options For back-compat, this can be omitted in favour of overwriting getPages. + * @param array|null $options For back-compat, this can be omitted in favour of overwriting + * getPages. */ public function __construct( array $options = null ) { if ( is_null( $options ) ) { @@ -430,7 +433,7 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule { // Avoid including ids or timestamps of revision/page tables so // that versions are not wasted $title = new TitleValue( (int)$row->page_namespace, $row->page_title ); - $titleInfo[ self::makeTitleKey( $title ) ] = [ + $titleInfo[self::makeTitleKey( $title )] = [ 'page_len' => $row->page_len, 'page_latest' => $row->page_latest, 'page_touched' => $row->page_touched, @@ -480,7 +483,7 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule { $func = [ static::class, 'fetchTitleInfo' ]; $fname = __METHOD__; - $cache = ObjectCache::getMainWANInstance(); + $cache = MediaWikiServices::getInstance()->getMainWANObjectCache(); $allInfo = $cache->getWithSetCallback( $cache->makeGlobalKey( 'resourceloader', 'titleinfo', $db->getDomainID(), $hash ), $cache::TTL_HOUR, @@ -526,14 +529,16 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule { * @param Title $title * @param Revision|null $old Prior page revision * @param Revision|null $new New page revision - * @param string $wikiId + * @param string $domain Database domain ID * @since 1.28 */ public static function invalidateModuleCache( - Title $title, Revision $old = null, Revision $new = null, $wikiId + Title $title, Revision $old = null, Revision $new = null, $domain ) { static $formats = [ CONTENT_FORMAT_CSS, CONTENT_FORMAT_JAVASCRIPT ]; + Assert::parameterType( 'string', $domain, '$domain' ); + // TODO: MCR: differentiate between page functionality and content model! // Not all pages containing CSS or JS have to be modules! [PageType] if ( $old && in_array( $old->getContentFormat(), $formats ) ) { @@ -545,8 +550,8 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule { } if ( $purge ) { - $cache = ObjectCache::getMainWANInstance(); - $key = $cache->makeGlobalKey( 'resourceloader', 'titleinfo', $wikiId ); + $cache = MediaWikiServices::getInstance()->getMainWANObjectCache(); + $key = $cache->makeGlobalKey( 'resourceloader', 'titleinfo', $domain ); $cache->touchCheckKey( $key ); } }