API: Allow returning parse warnings for action=parse
authorBaha <bmansurov@wikimedia.org>
Fri, 31 Mar 2017 18:59:35 +0000 (11:59 -0700)
committerBaha <bmansurov@wikimedia.org>
Fri, 31 Mar 2017 20:07:31 +0000 (13:07 -0700)
Passing in the 'parsewarnings' property will return warnings related
to parsing content.

Bug: T92634
Change-Id: I7e54765ee9a24ffb78e7763f73a520151023baf6

includes/api/ApiParse.php
includes/api/i18n/en.json
includes/api/i18n/qqq.json

index 287ffb7..b8d2641 100644 (file)
@@ -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 ],
index ab8a8a5..cd30960 100644 (file)
        "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-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 <var>$1text</var>.",
        "apihelp-parse-param-effectivelanglinks": "Includes language links supplied by extensions (for use with <kbd>$1prop=langlinks</kbd>).",
index cca3a3c..6e70653 100644 (file)
        "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}}",