From: Aaron Schulz Date: Fri, 9 Feb 2018 06:39:56 +0000 (-0800) Subject: Refactor Skin::buildSidebar() code style X-Git-Tag: 1.31.0-rc.0~634^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20%20%20%24self2%20.%20%20%20%22&var_mode_affiche=boucle?a=commitdiff_plain;h=6794ee6d5fe4e94d9929638856366ce23cb2f0e1;p=lhc%2Fweb%2Fwiklou.git Refactor Skin::buildSidebar() code style Change-Id: I054452ba6a83b3fc3c717a825acae6824d84bb49 --- diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php index bd43255965..4f271c7937 100644 --- a/includes/skins/Skin.php +++ b/includes/skins/Skin.php @@ -1256,27 +1256,26 @@ abstract class Skin extends ContextSource { function buildSidebar() { global $wgEnableSidebarCache, $wgSidebarCacheExpiry; - $callback = function () { + $callback = function ( $old = null, &$ttl = null ) { $bar = []; $this->addToSidebar( $bar, 'sidebar' ); Hooks::run( 'SkinBuildSidebar', [ $this, &$bar ] ); + if ( MessageCache::singleton()->isDisabled() ) { + $ttl = WANObjectCache::TTL_UNCACHEABLE; // bug T133069 + } return $bar; }; - if ( $wgEnableSidebarCache ) { - $cache = MediaWikiServices::getInstance()->getMainWANObjectCache(); - $sidebar = $cache->getWithSetCallback( + $cache = MediaWikiServices::getInstance()->getMainWANObjectCache(); + $sidebar = $wgEnableSidebarCache + ? $cache->getWithSetCallback( $cache->makeKey( 'sidebar', $this->getLanguage()->getCode() ), - MessageCache::singleton()->isDisabled() - ? $cache::TTL_UNCACHEABLE // bug T133069 - : $wgSidebarCacheExpiry, + $wgSidebarCacheExpiry, $callback, [ 'lockTSE' => 30 ] - ); - } else { - $sidebar = $callback(); - } + ) + : $callback(); // Apply post-processing to the cached value Hooks::run( 'SidebarBeforeOutput', [ $this, &$sidebar ] );