$popts = $this->makeParserOptions( $pageObj, $params );
- // Potentially cached
- $p_result = $this->getParsedContent( $pageObj, $popts, $pageid,
- isset( $prop['wikitext'] ) );
+ // Don't pollute the parser cache when setting options that aren't
+ // in ParserOptions::optionsHash()
+ $suppressCache =
+ $params['disablepp'] ||
+ $params['disablelimitreport'] ||
+ $params['preview'] ||
+ $params['sectionpreview'] ||
+ $params['disabletidy'];
+
+ if ( $suppressCache ) {
+ $this->content = $this->getContent( $pageObj, $pageid );
+ $p_result = $this->content->getParserOutput( $titleObj, null, $popts );
+ } else {
+ // Potentially cached
+ $p_result = $this->getParsedContent( $pageObj, $popts, $pageid,
+ isset( $prop['wikitext'] ) );
+ }
}
} else { // Not $oldid, $pageid, $page. Hence based on $text
$titleObj = Title::newFromText( $title );
protected function makeParserOptions( WikiPage $pageObj, array $params ) {
$popts = $pageObj->makeParserOptions( $this->getContext() );
- $popts->enableLimitReport( !$params['disablepp'] );
+ $popts->enableLimitReport( !$params['disablepp'] && !$params['disablelimitreport'] );
$popts->setIsPreview( $params['preview'] || $params['sectionpreview'] );
$popts->setIsSectionPreview( $params['sectionpreview'] );
$popts->setEditSection( !$params['disableeditsection'] );
+ if ( $params['disabletidy'] ) {
+ $popts->setTidy( false );
+ }
return $popts;
}
* @return ParserOutput
*/
private function getParsedContent( WikiPage $page, $popts, $pageId = null, $getWikitext = false ) {
- $this->content = $page->getContent( Revision::RAW ); //XXX: really raw?
+ $this->content = $this->getContent( $page, $pageId );
if ( $this->section !== false && $this->content !== null ) {
- $this->content = $this->getSectionContent(
- $this->content,
- !is_null( $pageId ) ? 'page id ' . $pageId : $page->getTitle()->getPrefixedText()
- );
-
// Not cached (save or load)
return $this->content->getParserOutput( $page->getTitle(), null, $popts );
}
}
/**
+ * Get the content for the given page and the requested section.
+ *
+ * @param WikiPage $page
+ * @param int $pageId
+ * @return Content
+ */
+ private function getContent( WikiPage $page, $pageId = null ) {
+ $content = $page->getContent( Revision::RAW ); //XXX: really raw?
+
+ if ( $this->section !== false && $content !== null ) {
+ $content = $this->getSectionContent(
+ $content,
+ !is_null( $pageId ) ? 'page id ' . $pageId : $page->getTitle()->getPrefixedText()
+ );
+ }
+ return $content;
+ }
+
+ /**
+ * Extract the requested section from the given Content
+ *
* @param Content $content
* @param string $what Identifies the content in error messages, e.g. page title.
* @return Content|bool
'sectiontitle' => array(
ApiBase::PARAM_TYPE => 'string',
),
- 'disablepp' => false,
+ 'disablepp' => array(
+ ApiBase::PARAM_DFLT => false,
+ ApiBase::PARAM_DEPRECATED => true,
+ ),
+ 'disablelimitreport' => false,
'disableeditsection' => false,
+ 'disabletidy' => false,
'generatexml' => array(
ApiBase::PARAM_DFLT => false,
ApiBase::PARAM_HELP_MSG => array(
"apihelp-parse-paramvalue-prop-iwlinks": "Gives interwiki links in the parsed wikitext.",
"apihelp-parse-paramvalue-prop-wikitext": "Gives the original wikitext that was parsed.",
"apihelp-parse-paramvalue-prop-properties": "Gives various properties defined in the parsed wikitext.",
- "apihelp-parse-paramvalue-prop-limitreportdata": "Gives the limit report in a structured way. Gives no data, when <var>$1disablepp</var> is set.",
- "apihelp-parse-paramvalue-prop-limitreporthtml": "Gives the HTML version of the limit report. Gives no data, when <var>$1disablepp</var> is set.",
+ "apihelp-parse-paramvalue-prop-limitreportdata": "Gives the limit report in a structured way. Gives no data, when <var>$1disablelimitreport</var> is set.",
+ "apihelp-parse-paramvalue-prop-limitreporthtml": "Gives the HTML version of the limit report. Gives no data, when <var>$1disablelimitreport</var> is set.",
"apihelp-parse-paramvalue-prop-parsetree": "The XML parse tree of revision content (requires content model <code>$1</code>)",
"apihelp-parse-param-pst": "Do a pre-save transform on the input before parsing it. Only valid when used with text.",
"apihelp-parse-param-onlypst": "Do a pre-save transform (PST) on the input, but don't parse it. Returns the same wikitext, after a PST has been applied. Only valid when used with <var>$1text</var>.",
"apihelp-parse-param-effectivelanglinks": "Includes language links supplied by extensions (for use with <kbd>$1prop=langlinks</kbd>).",
"apihelp-parse-param-section": "Only retrieve the content of this section number or when <kbd>new</kbd> generate a new section.\n\n<kbd>new</kbd> section is only honored when specifying <var>text</var>.",
"apihelp-parse-param-sectiontitle": "New section title when <var>section</var> is <kbd>new</kbd>.\n\nUnlike page editing, this does not fall back to <var>summary</var> when omitted or empty.",
- "apihelp-parse-param-disablepp": "Omit the preprocessor report (\"NewPP limit report\") from the parser output.",
+ "apihelp-parse-param-disablelimitreport": "Omit the limit report (\"NewPP limit report\") from the parser output.",
+ "apihelp-parse-param-disablepp": "Use <var>$1disablelimitreport</var> instead.",
"apihelp-parse-param-disableeditsection": "Omit edit section links from the parser output.",
+ "apihelp-parse-param-disabletidy": "Do not run HTML cleanup (e.g. tidy) on the parser output.",
"apihelp-parse-param-generatexml": "Generate XML parse tree (requires content model <code>$1</code>; replaced by <kbd>$2prop=parsetree</kbd>).",
"apihelp-parse-param-preview": "Parse in preview mode.",
"apihelp-parse-param-sectionpreview": "Parse in section preview mode (enables preview mode too).",
"apihelp-parse-param-effectivelanglinks": "{{doc-apihelp-param|parse|effectivelanglinks}}",
"apihelp-parse-param-section": "{{doc-apihelp-param|parse|section}}",
"apihelp-parse-param-sectiontitle": "{{doc-apihelp-param|parse|sectiontitle}}",
+ "apihelp-parse-param-disablelimitreport": "{{doc-apihelp-param|parse|disablelimitreport}}",
"apihelp-parse-param-disablepp": "{{doc-apihelp-param|parse|disablepp}}",
"apihelp-parse-param-disableeditsection": "{{doc-apihelp-param|parse|disableeditsection}}",
+ "apihelp-parse-param-disabletidy": "{{doc-apihelp-param|parse|disabletidy}}",
"apihelp-parse-param-generatexml": "{{doc-apihelp-param|parse|generatexml|params=* $1 - Value of the constant CONTENT_MODEL_WIKITEXT|paramstart=2}}",
"apihelp-parse-param-preview": "{{doc-apihelp-param|parse|preview}}",
"apihelp-parse-param-sectionpreview": "{{doc-apihelp-param|parse|sectionpreview}}",