X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fskins%2FSkin.php;h=40905a56dfc2ad1b5d74be3a274ab363d63a24e4;hb=d4a75173298f719d7dc6b46ef4530b84bcb40a6e;hp=e9d2f076b109fafec8dd735ce5eb567f361adfdf;hpb=36686633c7abfb5ba6ef41e6e5d2fd2b8c96e2ea;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php index e9d2f076b1..40905a56df 100644 --- a/includes/skins/Skin.php +++ b/includes/skins/Skin.php @@ -20,6 +20,8 @@ * @file */ +use MediaWiki\MediaWikiServices; + /** * @defgroup Skins Skins */ @@ -93,7 +95,7 @@ abstract class Skin extends ContextSource { static function normalizeKey( $key ) { global $wgDefaultSkin, $wgFallbackSkin; - $skinNames = Skin::getSkinNames(); + $skinNames = self::getSkinNames(); // Make keys lowercase for case-insensitive matching. $skinNames = array_change_key_case( $skinNames, CASE_LOWER ); @@ -1259,7 +1261,7 @@ abstract class Skin extends ContextSource { }; if ( $wgEnableSidebarCache ) { - $cache = ObjectCache::getMainWANInstance(); + $cache = MediaWikiServices::getInstance()->getMainWANObjectCache(); $sidebar = $cache->getWithSetCallback( $cache->makeKey( 'sidebar', $this->getLanguage()->getCode() ), MessageCache::singleton()->isDisabled() @@ -1391,7 +1393,6 @@ abstract class Skin extends ContextSource { * @return string */ function getNewtalks() { - $newMessagesAlert = ''; $user = $this->getUser(); $newtalks = $user->getNewMessageLinks(); @@ -1506,29 +1507,27 @@ abstract class Skin extends ContextSource { $notice = $msg->plain(); } - $cache = wfGetCache( CACHE_ANYTHING ); - // Use the extra hash appender to let eg SSL variants separately cache. - $key = $cache->makeKey( $name . $wgRenderHashAppend ); - $cachedNotice = $cache->get( $key ); - if ( is_array( $cachedNotice ) ) { - if ( md5( $notice ) == $cachedNotice['hash'] ) { - $notice = $cachedNotice['html']; - } else { - $needParse = true; + $cache = MediaWikiServices::getInstance()->getMainWANObjectCache(); + $parsed = $cache->getWithSetCallback( + // Use the extra hash appender to let eg SSL variants separately cache + // Key is verified with md5 hash of unparsed wikitext + $cache->makeKey( $name, $wgRenderHashAppend, md5( $notice ) ), + // TTL in seconds + 600, + function () use ( $notice ) { + return $this->getOutput()->parse( $notice ); } - } else { - $needParse = true; - } - - if ( $needParse ) { - $parsed = $this->getOutput()->parse( $notice ); - $cache->set( $key, [ 'html' => $parsed, 'hash' => md5( $notice ) ], 600 ); - $notice = $parsed; - } + ); - $notice = Html::rawElement( 'div', [ 'id' => 'localNotice', - 'lang' => $wgContLang->getHtmlCode(), 'dir' => $wgContLang->getDir() ], $notice ); - return $notice; + return Html::rawElement( + 'div', + [ + 'id' => 'localNotice', + 'lang' => $wgContLang->getHtmlCode(), + 'dir' => $wgContLang->getDir() + ], + $parsed + ); } /**