Deprecate $wgUseAjax, act as always-true
[lhc/web/wiklou.git] / includes / skins / Skin.php
index c95f1f5..f3276e8 100644 (file)
@@ -171,8 +171,6 @@ abstract class Skin extends ContextSource {
         * @return array Array of modules with helper keys for easy overriding
         */
        public function getDefaultModules() {
-               global $wgUseAjax, $wgEnableAPI, $wgEnableWriteAPI;
-
                $out = $this->getOutput();
                $config = $this->getConfig();
                $user = $out->getUser();
@@ -217,17 +215,15 @@ abstract class Skin extends ContextSource {
                }
 
                // Add various resources if required
-               if ( $wgUseAjax && $wgEnableAPI ) {
-                       if ( $wgEnableWriteAPI && $user->isLoggedIn()
-                               && $user->isAllowedAll( 'writeapi', 'viewmywatchlist', 'editmywatchlist' )
-                               && $this->getRelevantTitle()->canExist()
-                       ) {
-                               $modules['watch'][] = 'mediawiki.page.watch.ajax';
-                       }
-
-                       $modules['search'][] = 'mediawiki.searchSuggest';
+               if ( $user->isLoggedIn()
+                       && $user->isAllowedAll( 'writeapi', 'viewmywatchlist', 'editmywatchlist' )
+                       && $this->getRelevantTitle()->canExist()
+               ) {
+                       $modules['watch'][] = 'mediawiki.page.watch.ajax';
                }
 
+               $modules['search'][] = 'mediawiki.searchSuggest';
+
                if ( $user->getBoolOption( 'editsectiononrightclick' ) ) {
                        $modules['user'][] = 'mediawiki.action.view.rightClickEdit';
                }
@@ -767,15 +763,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
         */
@@ -1102,7 +1089,7 @@ abstract class Skin extends ContextSource {
        /* these are used extensively in SkinTemplate, but also some other places */
 
        /**
-        * @param string $urlaction
+        * @param string|string[] $urlaction
         * @return string
         */
        static function makeMainPageUrl( $urlaction = '' ) {
@@ -1119,7 +1106,7 @@ abstract class Skin extends ContextSource {
         * URL with the protocol specified.
         *
         * @param string $name Name of the Special page
-        * @param string $urlaction Query to append
+        * @param string|string[] $urlaction Query to append
         * @param string|null $proto Protocol to use or null for a local URL
         * @return string
         */
@@ -1135,7 +1122,7 @@ abstract class Skin extends ContextSource {
        /**
         * @param string $name
         * @param string $subpage
-        * @param string $urlaction
+        * @param string|string[] $urlaction
         * @return string
         */
        static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
@@ -1145,7 +1132,7 @@ abstract class Skin extends ContextSource {
 
        /**
         * @param string $name
-        * @param string $urlaction
+        * @param string|string[] $urlaction
         * @return string
         */
        static function makeI18nUrl( $name, $urlaction = '' ) {
@@ -1156,7 +1143,7 @@ abstract class Skin extends ContextSource {
 
        /**
         * @param string $name
-        * @param string $urlaction
+        * @param string|string[] $urlaction
         * @return string
         */
        static function makeUrl( $name, $urlaction = '' ) {
@@ -1183,7 +1170,7 @@ abstract class Skin extends ContextSource {
        /**
         * this can be passed the NS number as defined in Language.php
         * @param string $name
-        * @param string $urlaction
+        * @param string|string[] $urlaction
         * @param int $namespace
         * @return string
         */
@@ -1197,7 +1184,7 @@ abstract class Skin extends ContextSource {
        /**
         * these return an array with the 'href' and boolean 'exists'
         * @param string $name
-        * @param string $urlaction
+        * @param string|string[] $urlaction
         * @return array
         */
        static function makeUrlDetails( $name, $urlaction = '' ) {
@@ -1213,7 +1200,7 @@ abstract class Skin extends ContextSource {
        /**
         * Make URL details where the article exists (or at least it's convenient to think so)
         * @param string $name Article name
-        * @param string $urlaction
+        * @param string|string[] $urlaction
         * @return array
         */
        static function makeKnownUrlDetails( $name, $urlaction = '' ) {
@@ -1262,30 +1249,38 @@ abstract class Skin extends ContextSource {
         *
         * @return array
         */
-       function buildSidebar() {
+       public 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->makeKey( 'sidebar', $this->getLanguage()->getCode() ),
-                               MessageCache::singleton()->isDisabled()
-                                       ? $cache::TTL_UNCACHEABLE // bug T133069
-                                       : $wgSidebarCacheExpiry,
+               $msgCache = MessageCache::singleton();
+               $wanCache = MediaWikiServices::getInstance()->getMainWANObjectCache();
+
+               $sidebar = $wgEnableSidebarCache
+                       ? $wanCache->getWithSetCallback(
+                               $wanCache->makeKey( 'sidebar', $this->getLanguage()->getCode() ),
+                               $wgSidebarCacheExpiry,
                                $callback,
-                               [ 'lockTSE' => 30 ]
-                       );
-               } else {
-                       $sidebar = $callback();
-               }
+                               [
+                                       'checkKeys' => [
+                                               // Unless there is both no exact $code override nor an i18n definition
+                                               // in the the software, the only MediaWiki page to check is for $code.
+                                               $msgCache->getCheckKey( $this->getLanguage()->getCode() )
+                                       ],
+                                       'lockTSE' => 30
+                               ]
+                       )
+                       : $callback();
 
                // Apply post-processing to the cached value
                Hooks::run( 'SidebarBeforeOutput', [ $this, &$sidebar ] );