X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2Fresourceloader%2FResourceLoaderModule.php;h=a7fee8546b0b66f87b8bf7a3427a7562a718ce7e;hb=4821c63624e123043bddc54293cf6a286505955e;hp=53ed133be24d4f4e8ad8357be788aa23411ab4c0;hpb=ef752a33bbc796ec7c3d555e43c02f611af8c29a;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/resourceloader/ResourceLoaderModule.php b/includes/resourceloader/ResourceLoaderModule.php index 53ed133be2..a7fee8546b 100644 --- a/includes/resourceloader/ResourceLoaderModule.php +++ b/includes/resourceloader/ResourceLoaderModule.php @@ -146,10 +146,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { if ( is_string( $deprecationInfo ) ) { $warning .= "\n" . $deprecationInfo; } - return Xml::encodeJsCall( - 'mw.log.warn', - [ $warning ] - ); + return 'mw.log.warn(' . ResourceLoader::encodeJsonForScript( $warning ) . ');'; } else { return ''; } @@ -412,7 +409,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { * @return array List of files */ protected function getFileDependencies( ResourceLoaderContext $context ) { - $vary = $context->getSkin() . '|' . $context->getLanguage(); + $vary = self::getVary( $context ); // Try in-object cache first if ( !isset( $this->fileDeps[$vary] ) ) { @@ -447,7 +444,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { * @param string[] $files Array of file names */ public function setFileDependencies( ResourceLoaderContext $context, $files ) { - $vary = $context->getSkin() . '|' . $context->getLanguage(); + $vary = self::getVary( $context ); $this->fileDeps[$vary] = $files; } @@ -484,7 +481,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { } // The file deps list has changed, we want to update it. - $vary = $context->getSkin() . '|' . $context->getLanguage(); + $vary = self::getVary( $context ); $cache = ObjectCache::getLocalClusterInstance(); $key = $cache->makeKey( __METHOD__, $this->getName(), $vary ); $scopeLock = $cache->getScopedLock( $key, 0 ); @@ -504,10 +501,11 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { 'md_skin' => $vary, 'md_deps' => $deps, ], - [ 'md_module', 'md_skin' ], + [ [ 'md_module', 'md_skin' ] ], [ 'md_deps' => $deps, - ] + ], + __METHOD__ ); if ( $dbw->trxLevel() ) { @@ -953,8 +951,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { $cache = MediaWikiServices::getInstance()->getMainWANObjectCache(); return $cache->getWithSetCallback( $cache->makeGlobalKey( - 'resourceloader', - 'jsparse', + 'resourceloader-jsparse', self::$parseCacheVersion, md5( $contents ), $fileName @@ -1020,4 +1017,18 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { protected static function safeFileHash( $filePath ) { return FileContentsHasher::getFileContentsHash( $filePath ); } + + /** + * Get vary string. + * + * @internal For internal use only. + * @param ResourceLoaderContext $context + * @return string Vary string + */ + public static function getVary( ResourceLoaderContext $context ) { + return implode( '|', [ + $context->getSkin(), + $context->getLanguage(), + ] ); + } }