Merge "Refactor Skin::buildSidebar() code style"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 12 Feb 2018 06:58:20 +0000 (06:58 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 12 Feb 2018 06:58:20 +0000 (06:58 +0000)
includes/skins/Skin.php

index bd43255..4f271c7 100644 (file)
@@ -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 ] );