From 6794ee6d5fe4e94d9929638856366ce23cb2f0e1 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 8 Feb 2018 22:39:56 -0800 Subject: [PATCH] Refactor Skin::buildSidebar() code style Change-Id: I054452ba6a83b3fc3c717a825acae6824d84bb49 --- includes/skins/Skin.php | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) 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 ] ); -- 2.20.1