From: Bartosz DziewoƄski Date: Mon, 5 May 2014 16:58:34 +0000 (+0200) Subject: Article: Add RL modules for the ParserOutput when showing CSS/JS page X-Git-Tag: 1.31.0-rc.0~15314^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=commitdiff_plain;h=108d4aa2ba821066acc173725ea500d5693d8888;p=lhc%2Fweb%2Fwiklou.git Article: Add RL modules for the ParserOutput when showing CSS/JS page 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 --- diff --git a/includes/Article.php b/includes/Article.php index 2d3240b8cb..04972bc07e 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -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 ); } } } diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index dd3f3518d8..3aad38950a 100644 --- a/includes/diff/DifferenceEngine.php +++ b/includes/diff/DifferenceEngine.php @@ -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