Merge "Fix wrong @return type hints in Language::tsTo… methods"
[lhc/web/wiklou.git] / includes / OutputPage.php
index 6774072..c724207 100644 (file)
@@ -460,7 +460,7 @@ class OutputPage extends ContextSource {
         * @param string $script Raw HTML
         */
        function addScript( $script ) {
-               $this->mScripts .= $script . "\n";
+               $this->mScripts .= $script;
        }
 
        /**
@@ -516,7 +516,7 @@ class OutputPage extends ContextSource {
         * @param string $script JavaScript text, no "<script>" tags
         */
        public function addInlineScript( $script ) {
-               $this->mScripts .= Html::inlineScript( "\n$script\n" ) . "\n";
+               $this->mScripts .= Html::inlineScript( $script );
        }
 
        /**
@@ -2315,11 +2315,21 @@ class OutputPage extends ContextSource {
                        // adding of CSS or Javascript by extensions.
                        Hooks::run( 'BeforePageDisplay', [ &$this, &$sk ] );
 
-                       $sk->outputPage();
+                       try {
+                               $sk->outputPage();
+                       } catch ( Exception $e ) {
+                               ob_end_clean(); // bug T129657
+                               throw $e;
+                       }
                }
 
-               // This hook allows last minute changes to final overall output by modifying output buffer
-               Hooks::run( 'AfterFinalPageOutput', [ $this ] );
+               try {
+                       // This hook allows last minute changes to final overall output by modifying output buffer
+                       Hooks::run( 'AfterFinalPageOutput', [ $this ] );
+               } catch ( Exception $e ) {
+                       ob_end_clean(); // bug T129657
+                       throw $e;
+               }
 
                $this->sendCacheControl();
 
@@ -2942,7 +2952,7 @@ class OutputPage extends ContextSource {
         * @return string HTML fragment
         */
        function getHeadScripts() {
-               return $this->getInlineHeadScripts() . "\n" . $this->getExternalHeadScripts();
+               return $this->getInlineHeadScripts() . $this->getExternalHeadScripts();
        }
 
        /**
@@ -3209,7 +3219,8 @@ class OutputPage extends ContextSource {
                        'wgMonthNames' => $lang->getMonthNamesArray(),
                        'wgMonthNamesShort' => $lang->getMonthAbbreviationsArray(),
                        'wgRelevantPageName' => $relevantTitle->getPrefixedDBkey(),
-                       'wgRelevantArticleId' => $relevantTitle->getArticleId(),
+                       'wgRelevantArticleId' => $relevantTitle->getArticleID(),
+                       'wgRequestId' => WebRequest::getRequestId(),
                ];
 
                if ( $user->isLoggedIn() ) {
@@ -3624,7 +3635,7 @@ class OutputPage extends ContextSource {
                        # If wanted, and the interface is right-to-left, flip the CSS
                        $style_css = CSSJanus::transform( $style_css, true, false );
                }
-               $this->mInlineStyles .= Html::inlineStyle( $style_css ) . "\n";
+               $this->mInlineStyles .= Html::inlineStyle( $style_css );
        }
 
        /**
@@ -3676,7 +3687,7 @@ class OutputPage extends ContextSource {
                        if ( $this->getLanguage()->getDir() !== $wgContLang->getDir() ) {
                                $previewedCSS = CSSJanus::transform( $previewedCSS, true, false );
                        }
-                       $otherTags[] = Html::inlineStyle( $previewedCSS ) . "\n";
+                       $otherTags[] = Html::inlineStyle( $previewedCSS );
                } else {
                        // Load the user styles normally
                        $moduleStyles[] = 'user';
@@ -3715,7 +3726,7 @@ class OutputPage extends ContextSource {
                        ResourceLoaderModule::TYPE_STYLES
                );
                // Add normal styles added through addStyle()/addInlineStyle() here
-               $links[] = implode( "\n", $this->buildCssLinksArray() ) . $this->mInlineStyles;
+               $links[] = implode( '', $this->buildCssLinksArray() ) . $this->mInlineStyles;
                // Add marker tag to mark the place where the client-side
                // loader should inject dynamic styles
                // We use a <meta> tag with a made-up name for this because that's valid HTML