hierarchicalize(!) stat names
[lhc/web/wiklou.git] / includes / OutputPage.php
index 28d55e4..ba9fcba 100644 (file)
@@ -162,9 +162,6 @@ class OutputPage extends ContextSource {
        /** @var array */
        protected $mModuleStyles = array();
 
-       /** @var array */
-       protected $mModuleMessages = array();
-
        /** @var ResourceLoader */
        protected $mResourceLoader;
 
@@ -594,6 +591,19 @@ class OutputPage extends ContextSource {
         * @return array Array of module names
         */
        public function getModuleStyles( $filter = false, $position = null ) {
+               // T97420
+               $resourceLoader = $this->getResourceLoader();
+
+               foreach ( $this->mModuleStyles as $val ) {
+                       $module = $resourceLoader->getModule( $val );
+
+                       if ( $module instanceof ResourceLoaderModule && $module->isPositionDefault() ) {
+                               $warning = __METHOD__ . ': style module should define its position explicitly: ' . $val . ' ' . get_class( $module );
+                               wfDebugLog( 'resourceloader', $warning );
+                               wfLogWarning( $warning );
+                       }
+               }
+
                return $this->getModules( $filter, $position, 'mModuleStyles' );
        }
 
@@ -613,24 +623,24 @@ class OutputPage extends ContextSource {
        /**
         * Get the list of module messages to include on this page
         *
+        * @deprecated since 1.26 Obsolete
         * @param bool $filter
         * @param string|null $position
-        *
         * @return array Array of module names
         */
        public function getModuleMessages( $filter = false, $position = null ) {
-               return $this->getModules( $filter, $position, 'mModuleMessages' );
+               wfDeprecated( __METHOD__, '1.26' );
+               return array();
        }
 
        /**
-        * Add only messages of one or more modules recognized by the resource loader.
-        * Module messages added through this function will be loaded by the resource
-        * loader when the page loads.
+        * Load messages of one or more ResourceLoader modules.
         *
+        * @deprecated since 1.26 Use addModules() instead
         * @param string|array $modules Module name (string) or array of module names
         */
        public function addModuleMessages( $modules ) {
-               $this->mModuleMessages = array_merge( $this->mModuleMessages, (array)$modules );
+               wfDeprecated( __METHOD__, '1.26' );
        }
 
        /**
@@ -1401,8 +1411,10 @@ class OutputPage extends ContextSource {
 
        /**
         * Adds help link with an icon via page indicators.
-        * @param string $to
-        * @param bool $overrideBaseUrl
+        * Link target can be overridden by a local message containing a wikilink:
+        * the message key is: lowercase action or special page name + '-helppage'.
+        * @param string $to Target MediaWiki.org page title or encoded URL.
+        * @param bool $overrideBaseUrl Whether $url is a full URL, to avoid MW.o.
         * @since 1.25
         */
        public function addHelpLink( $to, $overrideBaseUrl = false ) {
@@ -1415,6 +1427,7 @@ class OutputPage extends ContextSource {
                        $toUrlencoded = wfUrlencode( str_replace( ' ', '_', $to ) );
                        $helpUrl = "//www.mediawiki.org/wiki/Special:MyLanguage/$toUrlencoded";
                }
+
                $link = Html::rawElement(
                        'a',
                        array(
@@ -1758,7 +1771,6 @@ class OutputPage extends ContextSource {
                $this->addModules( $parserOutput->getModules() );
                $this->addModuleScripts( $parserOutput->getModuleScripts() );
                $this->addModuleStyles( $parserOutput->getModuleStyles() );
-               $this->addModuleMessages( $parserOutput->getModuleMessages() );
                $this->addJsConfigVars( $parserOutput->getJsConfigVars() );
                $this->mPreventClickjacking = $this->mPreventClickjacking
                        || $parserOutput->preventClickjacking();
@@ -1805,7 +1817,6 @@ class OutputPage extends ContextSource {
                $this->addModules( $parserOutput->getModules() );
                $this->addModuleScripts( $parserOutput->getModuleScripts() );
                $this->addModuleStyles( $parserOutput->getModuleStyles() );
-               $this->addModuleMessages( $parserOutput->getModuleMessages() );
 
                $this->addJsConfigVars( $parserOutput->getJsConfigVars() );
        }
@@ -2869,13 +2880,7 @@ class OutputPage extends ContextSource {
                                // and we shouldn't be putting timestamps in Squid-cached HTML
                                $version = null;
                                if ( $group === 'user' ) {
-                                       // Get the maximum timestamp
-                                       $timestamp = 1;
-                                       foreach ( $grpModules as $module ) {
-                                               $timestamp = max( $timestamp, $module->getModifiedTime( $context ) );
-                                       }
-                                       // Add a version parameter so cache will break when things change
-                                       $query['version'] = wfTimestamp( TS_ISO_8601_BASIC, $timestamp );
+                                       $query['version'] = $resourceLoader->getCombinedVersion( $context, array_keys( $grpModules ) );
                                }
 
                                $query['modules'] = ResourceLoader::makePackedModulesString( array_keys( $grpModules ) );
@@ -2976,15 +2981,12 @@ class OutputPage extends ContextSource {
                // Load embeddable private modules before any loader links
                // This needs to be TYPE_COMBINED so these modules are properly wrapped
                // in mw.loader.implement() calls and deferred until mw.user is available
-               $embedScripts = array( 'user.options', 'user.tokens' );
+               $embedScripts = array( 'user.options' );
                $links[] = $this->makeResourceLoaderLink( $embedScripts, ResourceLoaderModule::TYPE_COMBINED );
+               // Separate user.tokens as otherwise caching will be allowed (T84960)
+               $links[] = $this->makeResourceLoaderLink( 'user.tokens', ResourceLoaderModule::TYPE_COMBINED );
 
                // Scripts and messages "only" requests marked for top inclusion
-               // Messages should go first
-               $links[] = $this->makeResourceLoaderLink(
-                       $this->getModuleMessages( true, 'top' ),
-                       ResourceLoaderModule::TYPE_MESSAGES
-               );
                $links[] = $this->makeResourceLoaderLink(
                        $this->getModuleScripts( true, 'top' ),
                        ResourceLoaderModule::TYPE_SCRIPTS
@@ -3018,19 +3020,20 @@ class OutputPage extends ContextSource {
         * @return string
         */
        function getScriptsForBottomQueue( $inHead ) {
-               // Scripts and messages "only" requests marked for bottom inclusion
+               // Scripts "only" requests marked for bottom inclusion
                // If we're in the <head>, use load() calls rather than <script src="..."> tags
-               // Messages should go first
                $links = array();
-               $links[] = $this->makeResourceLoaderLink( $this->getModuleMessages( true, 'bottom' ),
-                       ResourceLoaderModule::TYPE_MESSAGES, /* $useESI = */ false, /* $extraQuery = */ array(),
-                       /* $loadCall = */ $inHead
-               );
+
                $links[] = $this->makeResourceLoaderLink( $this->getModuleScripts( true, 'bottom' ),
                        ResourceLoaderModule::TYPE_SCRIPTS, /* $useESI = */ false, /* $extraQuery = */ array(),
                        /* $loadCall = */ $inHead
                );
 
+               $links[] = $this->makeResourceLoaderLink( $this->getModuleStyles( true, 'bottom' ),
+                       ResourceLoaderModule::TYPE_STYLES, /* $useESI = */ false, /* $extraQuery = */ array(),
+                       /* $loadCall = */ $inHead
+               );
+
                // Modules requests - let the client calculate dependencies and batch requests as it likes
                // Only load modules that have marked themselves for loading at the bottom
                $modules = $this->getModules( true, 'bottom' );
@@ -3088,6 +3091,9 @@ class OutputPage extends ContextSource {
         * @return string
         */
        function getBottomScripts() {
+               // In case the skin wants to add bottom CSS
+               $this->getSkin()->setupSkinUserCss( $this );
+
                // Optimise jQuery ready event cross-browser.
                // This also enforces $.isReady to be true at </body> which fixes the
                // mw.loader bug in Firefox with using document.write between </body>
@@ -3599,7 +3605,7 @@ class OutputPage extends ContextSource {
                $otherTags = ''; // Tags to append after the normal <link> tags
                $resourceLoader = $this->getResourceLoader();
 
-               $moduleStyles = $this->getModuleStyles();
+               $moduleStyles = $this->getModuleStyles( true, 'top' );
 
                // Per-site custom styles
                $moduleStyles[] = 'site';
@@ -3909,6 +3915,11 @@ class OutputPage extends ContextSource {
        public function enableOOUI() {
                OOUI\Theme::setSingleton( new OOUI\MediaWikiTheme() );
                OOUI\Element::setDefaultDir( $this->getLanguage()->getDir() );
-               $this->addModuleStyles( 'oojs-ui.styles' );
+               $this->addModuleStyles( array(
+                       'oojs-ui.styles',
+                       'oojs-ui.styles.icons',
+                       'oojs-ui.styles.indicators',
+                       'oojs-ui.styles.textures',
+               ) );
        }
 }