Merge "Remove uncalled Skin::getNamespaceNotice"
[lhc/web/wiklou.git] / includes / skins / Skin.php
index 4e6201c..dbb7c7f 100644 (file)
@@ -180,7 +180,7 @@ abstract class Skin extends ContextSource {
         * @return array Array of modules with helper keys for easy overriding
         */
        public function getDefaultModules() {
-               global $wgUseAjax, $wgAjaxWatch, $wgEnableAPI, $wgEnableWriteAPI;
+               global $wgUseAjax, $wgEnableAPI, $wgEnableWriteAPI;
 
                $out = $this->getOutput();
                $user = $out->getUser();
@@ -201,7 +201,7 @@ abstract class Skin extends ContextSource {
 
                // Add various resources if required
                if ( $wgUseAjax && $wgEnableAPI ) {
-                       if ( $wgEnableWriteAPI && $wgAjaxWatch && $user->isLoggedIn()
+                       if ( $wgEnableWriteAPI && $user->isLoggedIn()
                                && $user->isAllowedAll( 'writeapi', 'viewmywatchlist', 'editmywatchlist' )
                                && $this->getRelevantTitle()->canExist()
                        ) {
@@ -232,7 +232,7 @@ abstract class Skin extends ContextSource {
                $title = $this->getRelevantTitle();
 
                // User/talk link
-               if ( $user->isLoggedIn() || $this->showIPinHeader() ) {
+               if ( $user->isLoggedIn() ) {
                        $titles[] = $user->getUserPage();
                        $titles[] = $user->getTalkPage();
                }
@@ -725,12 +725,12 @@ abstract class Skin extends ContextSource {
        }
 
        /**
-        * Returns true if the IP should be shown in the header
-        * @return bool
+        * @deprecated since 1.27, feature removed
+        * @return bool Always false
         */
        function showIPinHeader() {
-               global $wgShowIPinHeader;
-               return $wgShowIPinHeader && session_id() != '';
+               wfDeprecated( __METHOD__, '1.27' );
+               return false;
        }
 
        /**
@@ -1225,29 +1225,31 @@ abstract class Skin extends ContextSource {
        function buildSidebar() {
                global $wgEnableSidebarCache, $wgSidebarCacheExpiry;
 
-               $cache = ObjectCache::getMainWANInstance();
-               $key = wfMemcKey( 'sidebar', $this->getLanguage()->getCode() );
-
-               if ( $wgEnableSidebarCache ) {
-                       $cachedsidebar = $cache->get( $key );
-                       if ( $cachedsidebar ) {
-                               Hooks::run( 'SidebarBeforeOutput', array( $this, &$cachedsidebar ) );
-
-                               return $cachedsidebar;
-                       }
-               }
+               $that = $this;
+               $callback = function () use ( $that ) {
+                       $bar = array();
+                       $that->addToSidebar( $bar, 'sidebar' );
+                       Hooks::run( 'SkinBuildSidebar', array( $that, &$bar ) );
 
-               $bar = array();
-               $this->addToSidebar( $bar, 'sidebar' );
+                       return $bar;
+               };
 
-               Hooks::run( 'SkinBuildSidebar', array( $this, &$bar ) );
                if ( $wgEnableSidebarCache ) {
-                       $cache->set( $key, $bar, $wgSidebarCacheExpiry );
+                       $cache = ObjectCache::getMainWANInstance();
+                       $sidebar = $cache->getWithSetCallback(
+                               $cache->makeKey( 'sidebar', $this->getLanguage()->getCode() ),
+                               $wgSidebarCacheExpiry,
+                               $callback,
+                               array( 'lockTSE' => 30 )
+                       );
+               } else {
+                       $sidebar = $callback();
                }
 
-               Hooks::run( 'SidebarBeforeOutput', array( $this, &$bar ) );
+               // Apply post-processing to the cached value
+               Hooks::run( 'SidebarBeforeOutput', array( $this, &$sidebar ) );
 
-               return $bar;
+               return $sidebar;
        }
 
        /**
@@ -1259,7 +1261,7 @@ abstract class Skin extends ContextSource {
         * @param array $bar
         * @param string $message
         */
-       function addToSidebar( &$bar, $message ) {
+       public function addToSidebar( &$bar, $message ) {
                $this->addToSidebarPlain( $bar, wfMessage( $message )->inContentLanguage()->plain() );
        }
 
@@ -1443,8 +1445,8 @@ abstract class Skin extends ContextSource {
                                )->numParams( $plural );
                        }
                        $newMessagesAlert = $newMessagesAlert->text();
-                       # Disable Squid cache
-                       $out->setSquidMaxage( 0 );
+                       # Disable CDN cache
+                       $out->setCdnMaxage( 0 );
                } elseif ( count( $newtalks ) ) {
                        $sep = $this->msg( 'newtalkseparator' )->escaped();
                        $msgs = array();
@@ -1457,7 +1459,7 @@ abstract class Skin extends ContextSource {
                        }
                        $parts = implode( $sep, $msgs );
                        $newMessagesAlert = $this->msg( 'youhavenewmessagesmulti' )->rawParams( $parts )->escaped();
-                       $out->setSquidMaxage( 0 );
+                       $out->setCdnMaxage( 0 );
                }
 
                return $newMessagesAlert;
@@ -1516,24 +1518,6 @@ abstract class Skin extends ContextSource {
                return $notice;
        }
 
-       /**
-        * Get a notice based on page's namespace
-        *
-        * @return string HTML fragment
-        */
-       function getNamespaceNotice() {
-
-               $key = 'namespacenotice-' . $this->getTitle()->getNsText();
-               $namespaceNotice = $this->getCachedNotice( $key );
-               if ( $namespaceNotice && substr( $namespaceNotice, 0, 7 ) != '<p>&lt;' ) {
-                       $namespaceNotice = '<div id="namespacebanner">' . $namespaceNotice . '</div>';
-               } else {
-                       $namespaceNotice = '';
-               }
-
-               return $namespaceNotice;
-       }
-
        /**
         * Get the site notice
         *