Add pst option to API difftotext
authorMatt Russell <public@matt-russell.com>
Mon, 31 Mar 2014 07:58:54 +0000 (07:58 +0000)
committerAnomie <bjorsch@wikimedia.org>
Wed, 21 Oct 2015 14:24:57 +0000 (14:24 +0000)
Adds the option difftotextpst to ApiQueryRevisionsBase.php, which will perform a
pre-save transform on the supplied text, before diffing it against the
requested revision.

Bug: T53155
Change-Id: Ia480e8cd4ceeeb0b2812dc8ec96650adb83c03af

RELEASE-NOTES-1.27
includes/api/ApiQueryRevisionsBase.php
includes/api/i18n/en.json
includes/api/i18n/qqq.json

index 7d4ac3d..617af0c 100644 (file)
@@ -76,6 +76,8 @@ production.
   into the redirect destination.
 * prop=imageinfo&iiprop=uploadwarning will no longer include the possibility of
   "was-deleted" warning.
+* Added difftotextpst to query=revisions which preforms a pre-save transform on
+  the text before diffing it.
 
 === Action API internal changes in 1.27 ===
 * ApiQueryORM removed.
index f8dbf23..609efb0 100644 (file)
@@ -31,8 +31,8 @@
  */
 abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
 
-       protected $limit, $diffto, $difftotext, $expandTemplates, $generateXML, $section,
-               $parseContent, $fetchContent, $contentFormat, $setParsedLimit = true;
+       protected $limit, $diffto, $difftotext, $difftotextpst, $expandTemplates, $generateXML,
+               $section, $parseContent, $fetchContent, $contentFormat, $setParsedLimit = true;
 
        protected $fld_ids = false, $fld_flags = false, $fld_timestamp = false,
                $fld_size = false, $fld_sha1 = false, $fld_comment = false,
@@ -61,6 +61,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
        protected function parseParameters( $params ) {
                if ( !is_null( $params['difftotext'] ) ) {
                        $this->difftotext = $params['difftotext'];
+                       $this->difftotextpst = $params['difftotextpst'];
                } elseif ( !is_null( $params['diffto'] ) ) {
                        if ( $params['diffto'] == 'cur' ) {
                                $params['diffto'] = 0;
@@ -385,6 +386,11 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
                                                        $this->contentFormat
                                                );
 
+                                               if ( $this->difftotextpst ) {
+                                                       $popts = ParserOptions::newFromContext( $this->getContext() );
+                                                       $difftocontent = $difftocontent->preSaveTransform( $title, $user, $popts );
+                                               }
+
                                                $engine = $handler->createDifferenceEngine( $context );
                                                $engine->setContent( $content, $difftocontent );
                                        }
@@ -490,6 +496,10 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
                                ApiBase::PARAM_DFLT => null,
                                ApiBase::PARAM_HELP_MSG => 'apihelp-query+revisions+base-param-difftotext',
                        ),
+                       'difftotextpst' => array(
+                               ApiBase::PARAM_DFLT => false,
+                               ApiBase::PARAM_HELP_MSG => 'apihelp-query+revisions+base-param-difftotextpst',
+                       ),
                        'contentformat' => array(
                                ApiBase::PARAM_TYPE => ContentHandler::getAllContentFormats(),
                                ApiBase::PARAM_DFLT => null,
index 589e5fd..450d83a 100644 (file)
        "apihelp-query+revisions+base-param-section": "Only retrieve the content of this section number.",
        "apihelp-query+revisions+base-param-diffto": "Revision ID to diff each revision to. Use <kbd>prev</kbd>, <kbd>next</kbd> and <kbd>cur</kbd> for the previous, next and current revision respectively.",
        "apihelp-query+revisions+base-param-difftotext": "Text to diff each revision to. Only diffs a limited number of revisions. Overrides <var>$1diffto</var>. If <var>$1section</var> is set, only that section will be diffed against this text.",
+       "apihelp-query+revisions+base-param-difftotextpst": "Perform a pre-save transform on the text before diffing it. Only valid when used with <var>$1difftotext</var>.",
        "apihelp-query+revisions+base-param-contentformat": "Serialization format used for <var>$1difftotext</var> and expected for output of content.",
 
        "apihelp-query+search-description": "Perform a full text search.",
index ea4251c..947c89b 100644 (file)
        "apihelp-query+revisions+base-param-section": "{{doc-apihelp-param|query+revisions+base|section|description=the \"section\" parameter to revision querying modules|noseealso=1}}",
        "apihelp-query+revisions+base-param-diffto": "{{doc-apihelp-param|query+revisions+base|diffto|description=the \"diffto\" parameter to revision querying modules|noseealso=1}}",
        "apihelp-query+revisions+base-param-difftotext": "{{doc-apihelp-param|query+revisions+base|difftotext|description=the \"difftotext\" parameter to revision querying modules|noseealso=1}}",
+       "apihelp-query+revisions+base-param-difftotextpst": "{{doc-apihelp-param|query+revisions+base|difftotextpst|description=the \"difftotextpst\" parameter to revision querying modules|noseealso=1}}",
        "apihelp-query+revisions+base-param-contentformat": "{{doc-apihelp-param|query+revisions+base|contentformat|description=the \"contentformat\" parameter to revision querying modules|noseealso=1}}",
        "apihelp-query+search-description": "{{doc-apihelp-description|query+search}}",
        "apihelp-query+search-param-search": "{{doc-apihelp-param|query+search|search}}",