jsduck: Sort list of globals in jsduck.json
[lhc/web/wiklou.git] / includes / OutputPage.php
index 6949f8b..67e9a4f 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 );
        }
 
        /**
@@ -780,7 +780,7 @@ class OutputPage extends ContextSource {
                        // bug 44570: the core page itself may not change, but resources might
                        $modifiedTimes['sepoch'] = wfTimestamp( TS_MW, time() - $config->get( 'SquidMaxage' ) );
                }
-               Hooks::run( 'OutputPageCheckLastModified', [ &$modifiedTimes ] );
+               Hooks::run( 'OutputPageCheckLastModified', [ &$modifiedTimes, $this ] );
 
                $maxModified = max( $modifiedTimes );
                $this->mLastModified = wfTimestamp( TS_RFC2822, $maxModified );
@@ -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();
        }
 
        /**
@@ -3210,6 +3220,7 @@ class OutputPage extends ContextSource {
                        'wgMonthNamesShort' => $lang->getMonthAbbreviationsArray(),
                        'wgRelevantPageName' => $relevantTitle->getPrefixedDBkey(),
                        '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