Article: Add RL modules for the ParserOutput when showing CSS/JS page
authorBartosz Dziewoński <matma.rex@gmail.com>
Mon, 5 May 2014 16:58:34 +0000 (18:58 +0200)
committerLegoktm <legoktm.wikipedia@gmail.com>
Fri, 20 Jun 2014 19:48:25 +0000 (19:48 +0000)
It previously added only the page HTML, which meant that ResourceLoader
modules associated with the page and other metadata was lost. This
affected the new way of doing things in SyntaxHighlight (Idf4ad439).

We still do not show categories, language links and other things
on the pages (although internally they behave just like in wikitext)

Also needs a fix in DifferenceEngine because our code sucks so much.

Bug: 64859
Change-Id: I5867985693b27ccc9195fddde8b922e67463e836

includes/Article.php
includes/diff/DifferenceEngine.php

index 2d3240b..04972bc 100644 (file)
@@ -822,8 +822,10 @@ class Article implements Page {
                                'ShowRawCssJs',
                                array( $this->mContentObject, $this->getTitle(), $outputPage ) )
                        ) {
+                               // If no legacy hooks ran, display the content of the parser output, including RL modules,
+                               // but excluding metadata like categories and language links
                                $po = $this->mContentObject->getParserOutput( $this->getTitle() );
-                               $outputPage->addHTML( $po->getText() );
+                               $outputPage->addParserOutputContent( $po );
                        }
                }
        }
index dd3f351..3aad389 100644 (file)
@@ -554,7 +554,7 @@ class DifferenceEngine extends ContextSource {
 
                        // NOTE: only needed for B/C: custom rendering of JS/CSS via hook
                        if ( $this->mNewPage->isCssJsSubpage() || $this->mNewPage->isCssOrJsPage() ) {
-                               // Stolen from Article::view --AG 2007-10-11
+                               // This needs to be synchronised with Article::showCssOrJsPage(), which sucks
                                // Give hooks a chance to customise the output
                                // @todo standardize this crap into one function
                                if ( ContentHandler::runLegacyHooks( 'ShowRawCssJs', array( $this->mNewContent, $this->mNewPage, $out ) ) ) {
@@ -562,8 +562,9 @@ class DifferenceEngine extends ContextSource {
                                        // use the content object's own rendering
                                        $cnt = $this->mNewRev->getContent();
                                        $po = $cnt ? $cnt->getParserOutput( $this->mNewRev->getTitle(), $this->mNewRev->getId() ) : null;
-                                       $txt = $po ? $po->getText() : '';
-                                       $out->addHTML( $txt );
+                                       if ( $po ) {
+                                               $out->addParserOutputContent( $po );
+                                       }
                                }
                        } elseif ( !wfRunHooks( 'ArticleContentViewCustom', array( $this->mNewContent, $this->mNewPage, $out ) ) ) {
                                // Handled by extension