r62080 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62079‎ | r62080 | r62081 >
Date:11:59, 7 February 2010
Author:conrad
Status:reverted (Comments)
Tags:
Comment:
Initialize parser properly in getTransclusionText()
Modified paths:
  • /trunk/phase3/includes/EditPage.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -15,7 +15,7 @@
1616 * (which in turn the browser understands, and can display).
1717 *
1818 * <pre>
19 - * There are five main entry points into the Parser class:
 19+ * There are six main entry points into the Parser class:
2020 * parse()
2121 * produces HTML output
2222 * preSaveTransform().
@@ -26,6 +26,8 @@
2727 * Cleans a signature before saving it to preferences
2828 * extractSections()
2929 * Extracts sections from an article for section editing
 30+ * getTransclusionText()
 31+ * Extracts the text of a template with only <includeonly>, etc., parsed
3032 *
3133 * Globals used:
3234 * objects: $wgLang, $wgContLang
@@ -82,6 +84,7 @@
8385 const OT_WIKI = 2;
8486 const OT_PREPROCESS = 3;
8587 const OT_MSG = 3;
 88+ const OT_INCLUDES = 4;
8689
8790 // Marker Suffix needs to be accessible staticly.
8891 const MARKER_SUFFIX = "-QINU\x7f";
@@ -500,7 +503,13 @@
501504 *
502505 * This is not called by the parser itself, see braceSubstitution for its transclusion.
503506 */
504 - public function getTransclusionText( $title ) {
 507+ public function getTransclusionText( $title, $options ) {
 508+ // Must initialize first
 509+ $this->clearState();
 510+ $this->setOutputType( self::OT_INCLUDES );
 511+ $this->mOptions = $options;
 512+ $this->setTitle( new FakeTitle );
 513+
505514 list( $text, $title ) = $this->getTemplateDom( $title );
506515 $flags = PPFrame::NO_ARGS | PPFrame::NO_TEMPLATES;
507516 return $this->getPreprocessor()->newFrame()->expand( $text, $flags );
Index: trunk/phase3/includes/EditPage.php
@@ -227,13 +227,13 @@
228228 * @return string The contents of the page.
229229 */
230230 protected function getPreloadedText( $preload ) {
231 - global $wgParser;
 231+ global $wgParser, $wgUser;
232232 if ( !empty( $this->mPreloadText ) ) {
233233 return $this->mPreloadText;
234234 } else {
235235 $preloadTitle = Title::newFromText( $preload );
236236 if ( isset( $preloadTitle ) && $preloadTitle->userCanRead() ) {
237 - return $wgParser->getTransclusionText( $preloadTitle );
 237+ return $wgParser->getTransclusionText( $preloadTitle, ParserOptions::newFromUser( $wgUser ) );
238238 }
239239 }
240240 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r62689Moving Conrad's recent parser work out to a branch. Reverted r62434, r62416, ...tstarling05:19, 19 February 2010

Comments

#Comment by Tim Starling (talk | contribs)   04:34, 19 February 2010

You don't appear to have any clue about what you are doing. I don't really have time for this, I'm going to have to move your work out to a branch.

#Comment by Conrad.Irwin (talk | contribs)   11:59, 19 February 2010

I have reopened the bugs this work fixed, and would like to discuss this with you at some point.

(bug 20339, bug 16714, bug 845, bug 7264, bug 5210, bug 22297, bug 4484, bug 5453)

Status & tagging log