jenkins-bot has submitted this change and it was merged.

Change subject: API: Rename disablepp and introduce disabletidy
......................................................................


API: Rename disablepp and introduce disabletidy

* Rename disablepp to disablelimitreport, since it does not disable the
  preprocessor (which is what PP stands for in "NewPP").
* Introduce new option "disabletidy" for T89331
* Suppress the use of the parser cache when options are specified that
  affect the output but are not in ParserOptions::optionsHash(). This
  was already broken, but the damage was fairly limited since the
  options rarely caused user-visible changes. It would break very badly
  if I use the disabletidy option for what I am intending.

Change-Id: I4b0e55fe34e237a68450f583bf59bab7dd703a29
---
M includes/api/ApiParse.php
M includes/api/i18n/en.json
M includes/api/i18n/qqq.json
3 files changed, 56 insertions(+), 14 deletions(-)

Approvals:
  Ori.livneh: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php
index 1b8f6d9..d67655b 100644
--- a/includes/api/ApiParse.php
+++ b/includes/api/ApiParse.php
@@ -169,9 +169,23 @@
 
                                $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 );
@@ -464,10 +478,13 @@
        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;
        }
@@ -480,14 +497,9 @@
         * @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 );
                }
@@ -506,6 +518,27 @@
        }
 
        /**
+        * 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
@@ -762,8 +795,13 @@
                        '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(
diff --git a/includes/api/i18n/en.json b/includes/api/i18n/en.json
index d3189c6..396f5da 100644
--- a/includes/api/i18n/en.json
+++ b/includes/api/i18n/en.json
@@ -302,16 +302,18 @@
        "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).",
diff --git a/includes/api/i18n/qqq.json b/includes/api/i18n/qqq.json
index 5ac1e0d..ef803f5 100644
--- a/includes/api/i18n/qqq.json
+++ b/includes/api/i18n/qqq.json
@@ -292,8 +292,10 @@
        "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}}",

-- 
To view, visit https://gerrit.wikimedia.org/r/233344
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4b0e55fe34e237a68450f583bf59bab7dd703a29
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Tim Starling <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Cscott <[email protected]>
Gerrit-Reviewer: Jackmcbarn <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: Raimond Spekking <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: Tim Starling <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to