X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fskins%2FSkin.php;h=9c4ac507291c0bdf29a7912fe9aba27750b1f2f6;hb=a01d8be82c6eb6a39b9715b40b71f78817161a2a;hp=4f271c79373a0aa56bf3cd27302cc122cd32a56f;hpb=433e3d92627b8c34952e387ad948c393b8a5182a;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php index 4f271c7937..9c4ac50729 100644 --- a/includes/skins/Skin.php +++ b/includes/skins/Skin.php @@ -166,17 +166,20 @@ abstract class Skin extends ContextSource { * It is recommended that skins wishing to override call parent::getDefaultModules() * and substitute out any modules they wish to change by using a key to look them up * - * For style modules, use setupSkinUserCss() instead. + * Any modules defined with the 'styles' key will be added as render blocking CSS via + * Output::addModuleStyles. Similarly, each key should refer to a list of modules * * @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(); $modules = [ + // Styles key sets render blocking styles + // Unlike other keys in this definition it is an associative array + // where each key is the group name and points to a list of modules + 'styles' => [], // modules not specific to any specific skin or page 'core' => [ // Enforce various default modules for all pages and all skins @@ -217,17 +220,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'; } @@ -1093,7 +1094,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 = '' ) { @@ -1110,7 +1111,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 */ @@ -1126,7 +1127,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 = '' ) { @@ -1136,7 +1137,7 @@ abstract class Skin extends ContextSource { /** * @param string $name - * @param string $urlaction + * @param string|string[] $urlaction * @return string */ static function makeI18nUrl( $name, $urlaction = '' ) { @@ -1147,7 +1148,7 @@ abstract class Skin extends ContextSource { /** * @param string $name - * @param string $urlaction + * @param string|string[] $urlaction * @return string */ static function makeUrl( $name, $urlaction = '' ) { @@ -1174,7 +1175,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 */ @@ -1188,7 +1189,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 = '' ) { @@ -1204,7 +1205,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 = '' ) { @@ -1253,7 +1254,7 @@ abstract class Skin extends ContextSource { * * @return array */ - function buildSidebar() { + public function buildSidebar() { global $wgEnableSidebarCache, $wgSidebarCacheExpiry; $callback = function ( $old = null, &$ttl = null ) { @@ -1267,13 +1268,22 @@ abstract class Skin extends ContextSource { return $bar; }; - $cache = MediaWikiServices::getInstance()->getMainWANObjectCache(); + $msgCache = MessageCache::singleton(); + $wanCache = MediaWikiServices::getInstance()->getMainWANObjectCache(); + $sidebar = $wgEnableSidebarCache - ? $cache->getWithSetCallback( - $cache->makeKey( 'sidebar', $this->getLanguage()->getCode() ), + ? $wanCache->getWithSetCallback( + $wanCache->makeKey( 'sidebar', $this->getLanguage()->getCode() ), $wgSidebarCacheExpiry, $callback, - [ 'lockTSE' => 30 ] + [ + '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();