From 2326d420c78ab71c1f13542973a695a80e6202f7 Mon Sep 17 00:00:00 2001 From: Baha Date: Fri, 31 Mar 2017 11:59:35 -0700 Subject: [PATCH] API: Allow returning parse warnings for action=parse Passing in the 'parsewarnings' property will return warnings related to parsing content. Bug: T92634 Change-Id: I7e54765ee9a24ffb78e7763f73a520151023baf6 --- includes/api/ApiParse.php | 8 +++++++- includes/api/i18n/en.json | 1 + includes/api/i18n/qqq.json | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index 287ffb7c0e..b8d2641f91 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -340,6 +340,9 @@ class ApiParse extends ApiBase { if ( isset( $prop['sections'] ) ) { $result_array['sections'] = $p_result->getSections(); } + if ( isset( $prop['parsewarnings'] ) ) { + $result_array['parsewarnings'] = $p_result->getWarnings(); + } if ( isset( $prop['displaytitle'] ) ) { $result_array['displaytitle'] = $p_result->getDisplayTitle() ?: @@ -452,6 +455,7 @@ class ApiParse extends ApiBase { 'modulestyles' => 'm', 'properties' => 'pp', 'limitreportdata' => 'lr', + 'parsewarnings' => 'pw' ]; $this->setIndexedTagNames( $result_array, $result_mapping ); $result->addValue( null, $this->getModuleName(), $result_array ); @@ -751,7 +755,8 @@ class ApiParse extends ApiBase { ], 'prop' => [ ApiBase::PARAM_DFLT => 'text|langlinks|categories|links|templates|' . - 'images|externallinks|sections|revid|displaytitle|iwlinks|properties', + 'images|externallinks|sections|revid|displaytitle|iwlinks|' . + 'properties|parsewarnings', ApiBase::PARAM_ISMULTI => true, ApiBase::PARAM_TYPE => [ 'text', @@ -777,6 +782,7 @@ class ApiParse extends ApiBase { 'limitreportdata', 'limitreporthtml', 'parsetree', + 'parsewarnings' ], ApiBase::PARAM_HELP_MSG_PER_VALUE => [ 'parsetree' => [ 'apihelp-parse-paramvalue-prop-parsetree', CONTENT_MODEL_WIKITEXT ], diff --git a/includes/api/i18n/en.json b/includes/api/i18n/en.json index ab8a8a56bd..cd30960ebc 100644 --- a/includes/api/i18n/en.json +++ b/includes/api/i18n/en.json @@ -348,6 +348,7 @@ "apihelp-parse-paramvalue-prop-limitreportdata": "Gives the limit report in a structured way. Gives no data, when $1disablelimitreport is set.", "apihelp-parse-paramvalue-prop-limitreporthtml": "Gives the HTML version of the limit report. Gives no data, when $1disablelimitreport is set.", "apihelp-parse-paramvalue-prop-parsetree": "The XML parse tree of revision content (requires content model $1)", + "apihelp-parse-paramvalue-prop-parsewarnings": "Gives the warnings that occurred while parsing content.", "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 $1text.", "apihelp-parse-param-effectivelanglinks": "Includes language links supplied by extensions (for use with $1prop=langlinks).", diff --git a/includes/api/i18n/qqq.json b/includes/api/i18n/qqq.json index cca3a3c6e6..6e70653463 100644 --- a/includes/api/i18n/qqq.json +++ b/includes/api/i18n/qqq.json @@ -330,6 +330,7 @@ "apihelp-parse-paramvalue-prop-limitreportdata": "{{doc-apihelp-paramvalue|parse|prop|limitreportdata}}", "apihelp-parse-paramvalue-prop-limitreporthtml": "{{doc-apihelp-paramvalue|parse|prop|limitreporthtml}}", "apihelp-parse-paramvalue-prop-parsetree": "{{doc-apihelp-paramvalue|parse|prop|parsetree|params=* $1 - Value of the constant CONTENT_MODEL_WIKITEXT|paramstart=2}}", + "apihelp-parse-paramvalue-prop-parsewarnings": "{{doc-apihelp-paramvalue|parse|prop|parsewarnings}}", "apihelp-parse-param-pst": "{{doc-apihelp-param|parse|pst}}", "apihelp-parse-param-onlypst": "{{doc-apihelp-param|parse|onlypst}}", "apihelp-parse-param-effectivelanglinks": "{{doc-apihelp-param|parse|effectivelanglinks}}", -- 2.20.1