Made loadFromFileCache() always disable $wgOut regardless of whether compression...
[lhc/web/wiklou.git] / includes / OutputPage.php
index 955b6a0..9723690 100644 (file)
@@ -813,7 +813,7 @@ class OutputPage extends ContextSource {
                $this->mPagetitle = $nameWithTags;
 
                # change "<i>foo&amp;bar</i>" to "foo&bar"
-               $this->setHTMLTitle( $this->msg( 'pagetitle' )->rawParams( htmlspecialchars( Sanitizer::stripAllTags( $nameWithTags ) ) ) );
+               $this->setHTMLTitle( $this->msg( 'pagetitle' )->rawParams( Sanitizer::stripAllTags( $nameWithTags ) ) );
        }
 
        /**
@@ -1075,7 +1075,7 @@ class OutputPage extends ContextSource {
        /**
         * Add new language links
         *
-        * @param $newLinkArray Associative array mapping language code to the page
+        * @param $newLinkArray array Associative array mapping language code to the page
         *                      name
         */
        public function addLanguageLinks( $newLinkArray ) {
@@ -1085,7 +1085,7 @@ class OutputPage extends ContextSource {
        /**
         * Reset the language links and add new language links
         *
-        * @param $newLinkArray Associative array mapping language code to the page
+        * @param $newLinkArray array Associative array mapping language code to the page
         *                      name
         */
        public function setLanguageLinks( $newLinkArray ) {
@@ -1366,7 +1366,7 @@ class OutputPage extends ContextSource {
        /**
         * Set the displayed file version
         *
-        * @param $file File|false
+        * @param $file File|bool
         * @return Mixed: previous value
         */
        public function setFileVersion( $file ) {
@@ -1467,8 +1467,6 @@ class OutputPage extends ContextSource {
 
                wfProfileIn( __METHOD__ );
 
-               wfIncrStats( 'pcache_not_possible' );
-
                $popts = $this->parserOptions();
                $oldTidy = $popts->setTidy( $tidy );
                $popts->setInterfaceMessage( (bool) $interface );
@@ -2250,6 +2248,7 @@ class OutputPage extends ContextSource {
                        $params = array(
                                'id'   => 'wpTextbox1',
                                'name' => 'wpTextbox1',
+                               'cols' => $this->getUser()->getOption( 'cols' ),
                                'rows' => $this->getUser()->getOption( 'rows' ),
                                'readonly' => 'readonly',
                                'lang' => $pageLang->getHtmlCode(),
@@ -2381,6 +2380,7 @@ $templates
         */
        public function headElement( Skin $sk, $includeStyle = true ) {
                global $wgContLang;
+
                $userdir = $this->getLanguage()->getDir();
                $sitedir = $wgContLang->getDir();
 
@@ -2425,6 +2425,7 @@ $templates
                }
                $bodyAttrs['class'] .= ' ' . $sk->getPageClasses( $this->getTitle() );
                $bodyAttrs['class'] .= ' skin-' . Sanitizer::escapeClass( $sk->getSkinName() );
+               $bodyAttrs['class'] .= ' action-' . Sanitizer::escapeClass( Action::getActionName( $this->getContext() ) );
 
                $sk->addToBodyAttributes( $this, $bodyAttrs ); // Allow skins to add body attributes they need
                wfRunHooks( 'OutputPageBodyAttributes', array( $this, $sk, &$bodyAttrs ) );
@@ -2438,12 +2439,12 @@ $templates
         * Add the default ResourceLoader modules to this object
         */
        private function addDefaultModules() {
-               global $wgIncludeLegacyJavaScript, $wgUseAjax, $wgAjaxWatch, $wgEnableMWSuggest;
+               global $wgIncludeLegacyJavaScript, $wgPreloadJavaScriptMwUtil, $wgUseAjax,
+                       $wgAjaxWatch, $wgEnableMWSuggest;
 
                // Add base resources
                $this->addModules( array(
                        'mediawiki.user',
-                       'mediawiki.util',
                        'mediawiki.page.startup',
                        'mediawiki.page.ready',
                ) );
@@ -2451,6 +2452,12 @@ $templates
                        $this->addModules( 'mediawiki.legacy.wikibits' );
                }
 
+               if ( $wgPreloadJavaScriptMwUtil ) {
+                       $this->addModules( 'mediawiki.util' );
+               }
+
+               MWDebug::addModules( $this );
+
                // Add various resources if required
                if ( $wgUseAjax ) {
                        $this->addModules( 'mediawiki.legacy.ajax' );
@@ -2674,6 +2681,8 @@ $templates
                );
 
                // 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' );
                $scripts .= $this->makeResourceLoaderLink( $embedScripts, ResourceLoaderModule::TYPE_COMBINED );
 
@@ -2688,9 +2697,7 @@ $templates
                if ( $modules ) {
                        $scripts .= Html::inlineScript(
                                ResourceLoader::makeLoaderConditionalScript(
-                                       "mw.loader.setBlocking( true );\n" .
-                                       Xml::encodeJsCall( 'mw.loader.load', array( $modules ) ) .
-                                       "\nmw.loader.setBlocking( false );"
+                                       Xml::encodeJsCall( 'mw.loader.load', array( $modules, null, true ) )
                                )
                        );
                }
@@ -2822,15 +2829,22 @@ $templates
         * @return array
         */
        public function getJSVars() {
-               global $wgUseAjax, $wgEnableMWSuggest, $mediaWiki;
+               global $wgUseAjax, $wgEnableMWSuggest;
+
+               $latestRevID = 0;
+               $pageID = 0;
+               $canonicalName = false; # bug 21115
 
                $title = $this->getTitle();
                $ns = $title->getNamespace();
                $nsname = MWNamespace::exists( $ns ) ? MWNamespace::getCanonicalName( $ns ) : $title->getNsText();
+
                if ( $ns == NS_SPECIAL ) {
                        list( $canonicalName, /*...*/ ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
-               } else {
-                       $canonicalName = false; # bug 21115
+               } elseif ( $this->canUseWikiPage() ) {
+                       $wikiPage = $this->getWikiPage();
+                       $latestRevID = $wikiPage->getLatest();
+                       $pageID = $wikiPage->getId();
                }
 
                $lang = $title->getPageLanguage();
@@ -2855,10 +2869,10 @@ $templates
                        'wgNamespaceNumber' => $title->getNamespace(),
                        'wgPageName' => $title->getPrefixedDBKey(),
                        'wgTitle' => $title->getText(),
-                       'wgCurRevisionId' => $title->getLatestRevID(),
-                       'wgArticleId' => $title->getArticleId(),
+                       'wgCurRevisionId' => $latestRevID,
+                       'wgArticleId' => $pageID,
                        'wgIsArticle' => $this->isArticle(),
-                       'wgAction' => $mediaWiki->getPerformedAction(),
+                       'wgAction' => Action::getActionName( $this->getContext() ),
                        'wgUserName' => $this->getUser()->isAnon() ? null : $this->getUser()->getName(),
                        'wgUserGroups' => $this->getUser()->getEffectiveGroups(),
                        'wgCategories' => $this->getCategories(),
@@ -3256,7 +3270,7 @@ $templates
 
                // Per-user preference styles
                if ( $wgAllowUserCssPrefs ) {
-                       $moduleStyles[] = 'user.options';
+                       $moduleStyles[] = 'user.cssprefs';
                }
 
                foreach ( $moduleStyles as $name ) {