X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fskins%2FSkin.php;h=a8f9d0cbcba1403abace5f83fb80f3eafbf8e1f6;hp=6834ca5fad5846bf2af9d885c5f125f1a54680df;hb=884a54e910dc5b6f961b43a1f808da93bf2c8af3;hpb=84694a9d592ee5f93e41a5e7dc06eaa40c669c0c diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php index 6834ca5fad..a8f9d0cbcb 100644 --- a/includes/skins/Skin.php +++ b/includes/skins/Skin.php @@ -20,6 +20,8 @@ * @file */ +use MediaWiki\MediaWikiServices; + /** * @defgroup Skins Skins */ @@ -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() @@ -1505,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 + ); } /**