From a6a6d55c5397153054fda3aedc570b9d3e31110e Mon Sep 17 00:00:00 2001 From: Matt Russell Date: Mon, 31 Mar 2014 07:58:54 +0000 Subject: [PATCH] Add pst option to API difftotext 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 | 2 ++ includes/api/ApiQueryRevisionsBase.php | 14 ++++++++++++-- includes/api/i18n/en.json | 1 + includes/api/i18n/qqq.json | 1 + 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES-1.27 b/RELEASE-NOTES-1.27 index 7d4ac3dcb4..617af0ca57 100644 --- a/RELEASE-NOTES-1.27 +++ b/RELEASE-NOTES-1.27 @@ -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. diff --git a/includes/api/ApiQueryRevisionsBase.php b/includes/api/ApiQueryRevisionsBase.php index f8dbf23c2a..609efb00f0 100644 --- a/includes/api/ApiQueryRevisionsBase.php +++ b/includes/api/ApiQueryRevisionsBase.php @@ -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, diff --git a/includes/api/i18n/en.json b/includes/api/i18n/en.json index 589e5fd819..450d83ab92 100644 --- a/includes/api/i18n/en.json +++ b/includes/api/i18n/en.json @@ -1028,6 +1028,7 @@ "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 prev, next and cur 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 $1diffto. If $1section 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 $1difftotext.", "apihelp-query+revisions+base-param-contentformat": "Serialization format used for $1difftotext and expected for output of content.", "apihelp-query+search-description": "Perform a full text search.", diff --git a/includes/api/i18n/qqq.json b/includes/api/i18n/qqq.json index ea4251c414..947c89b462 100644 --- a/includes/api/i18n/qqq.json +++ b/includes/api/i18n/qqq.json @@ -958,6 +958,7 @@ "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}}", -- 2.20.1