Merge "Add SPARQL client to core"
[lhc/web/wiklou.git] / includes / skins / Skin.php
index 167b49d..4f271c7 100644 (file)
@@ -34,7 +34,11 @@ use MediaWiki\MediaWikiServices;
  * @ingroup Skins
  */
 abstract class Skin extends ContextSource {
+       /**
+        * @var string|null
+        */
        protected $skinname = null;
+
        protected $mRelevantTitle = null;
        protected $mRelevantUser = null;
 
@@ -134,7 +138,17 @@ abstract class Skin extends ContextSource {
        }
 
        /**
-        * @return string Skin name
+        * @since 1.31
+        * @param string|null $skinname
+        */
+       public function __construct( $skinname = null ) {
+               if ( is_string( $skinname ) ) {
+                       $this->skinname = $skinname;
+               }
+       }
+
+       /**
+        * @return string|null Skin name
         */
        public function getSkinName() {
                return $this->skinname;
@@ -753,15 +767,6 @@ abstract class Skin extends ContextSource {
                return $subpages;
        }
 
-       /**
-        * @deprecated since 1.27, feature removed
-        * @return bool Always false
-        */
-       function showIPinHeader() {
-               wfDeprecated( __METHOD__, '1.27' );
-               return false;
-       }
-
        /**
         * @return string
         */
@@ -897,7 +902,7 @@ abstract class Skin extends ContextSource {
                        $s = '';
                }
 
-               if ( wfGetLB()->getLaggedReplicaMode() ) {
+               if ( MediaWikiServices::getInstance()->getDBLoadBalancer()->getLaggedReplicaMode() ) {
                        $s .= ' <strong>' . $this->msg( 'laggedslavemode' )->parse() . '</strong>';
                }
 
@@ -1251,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 ] );