jenkins-bot has submitted this change and it was merged.
Change subject: OutputPage: Add addParserOutputContent() for more fine-grained
control
......................................................................
OutputPage: Add addParserOutputContent() for more fine-grained control
We previously had addParserOutput(), which added everything and did
some other magic, and addParserOutputNoText() which, as the same says,
added everything but the text.
I renamed addParserOutputNoText() to addParserOutputMetadata() and
created two more functions:
* addParserOutputText(): This is almost identical to adding the raw
HTML, but calls the OutputPageBeforeHTML hook like other
addParserOutput*() methods.
* addParserOutputContent(): Like addParserOutputText(), but also adds
the ResourceLoader modules and variables associated with the parser
output. This is important especially for some extensions like
TemplateData or SyntaxHighlight which add styles to the page to
enhance the display.
Change-Id: Iead541886fd1ccdbdf1cb06af71b34cd04644985
---
M includes/OutputPage.php
1 file changed, 49 insertions(+), 6 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
Objections:
Daniel Kinzler: There's a problem with this change, please improve
diff --git a/includes/OutputPage.php b/includes/OutputPage.php
index 8fd7812..612dc32 100644
--- a/includes/OutputPage.php
+++ b/includes/OutputPage.php
@@ -1621,11 +1621,25 @@
}
/**
- * Add a ParserOutput object, but without Html
+ * Add a ParserOutput object, but without Html.
*
+ * @deprecated since 1.24, use addParserOutputMetadata() instead.
* @param ParserOutput $parserOutput
*/
public function addParserOutputNoText( &$parserOutput ) {
+ wfDeprecated( __METHOD__, '1.24' );
+ $this->addParserOutputMetadata( $parserOutput );
+ }
+
+ /**
+ * Add all metadata associated with a ParserOutput object, but without
the actual HTML. This
+ * includes categories, language links, ResourceLoader modules, effects
of certain magic words,
+ * and so on.
+ *
+ * @since 1.24
+ * @param ParserOutput $parserOutput
+ */
+ public function addParserOutputMetadata( &$parserOutput ) {
$this->mLanguageLinks += $parserOutput->getLanguageLinks();
$this->addCategoryLinks( $parserOutput->getCategories() );
$this->mNewSectionLink = $parserOutput->getNewSection();
@@ -1673,21 +1687,50 @@
}
/**
- * Add a ParserOutput object
+ * Add the HTML and enhancements for it (like ResourceLoader modules)
associated with a
+ * ParserOutput object, without any other metadata.
+ *
+ * @since 1.24
+ * @param ParserOutput $parserOutput
+ */
+ public function addParserOutputContent( &$parserOutput ) {
+ $this->addParserOutputText( $parserOutput );
+
+ $this->addModules( $parserOutput->getModules() );
+ $this->addModuleScripts( $parserOutput->getModuleScripts() );
+ $this->addModuleStyles( $parserOutput->getModuleStyles() );
+ $this->addModuleMessages( $parserOutput->getModuleMessages() );
+
+ $this->addJsConfigVars( $parserOutput->getJsConfigVars() );
+ }
+
+ /**
+ * Add the HTML associated with a ParserOutput object, without any
metadata.
+ *
+ * @since 1.24
+ * @param ParserOutput $parserOutput
+ */
+ public function addParserOutputText( &$parserOutput ) {
+ $text = $parserOutput->getText();
+ wfRunHooks( 'OutputPageBeforeHTML', array( &$this, &$text ) );
+ $this->addHTML( $text );
+ }
+
+ /**
+ * Add everything from a ParserOutput object.
*
* @param ParserOutput $parserOutput
*/
function addParserOutput( &$parserOutput ) {
- $this->addParserOutputNoText( $parserOutput );
+ $this->addParserOutputMetadata( $parserOutput );
$parserOutput->setTOCEnabled( $this->mEnableTOC );
// Touch section edit links only if not previously disabled
if ( $parserOutput->getEditSectionTokens() ) {
$parserOutput->setEditSectionTokens(
$this->mEnableSectionEditLinks );
}
- $text = $parserOutput->getText();
- wfRunHooks( 'OutputPageBeforeHTML', array( &$this, &$text ) );
- $this->addHTML( $text );
+
+ $this->addParserOutputText( $parserOutput );
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/132232
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iead541886fd1ccdbdf1cb06af71b34cd04644985
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: Brion VIBBER <[email protected]>
Gerrit-Reviewer: Daniel Friesen <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Fomafix
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: TheDJ <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits