From cb68ff02309f090bd297e0a49fc81727c4bd3371 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Mon, 13 Jun 2016 03:09:45 -0700 Subject: [PATCH] Send the edit summary/user to the edit stash API This can be useful for pre-caching AbuseFilter check results Bug: T137698 Change-Id: I03e3924408a2a5da09a411b66d09958a1b78cb99 --- docs/hooks.txt | 2 ++ includes/api/ApiStashEdit.php | 13 +++++++++---- includes/api/i18n/en.json | 1 + includes/api/i18n/qqq.json | 1 + .../mediawiki.action/mediawiki.action.edit.stash.js | 1 + 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index e0b91f21c2..5c69d2aac0 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -2402,6 +2402,8 @@ that tests continue to run properly. $page: the WikiPage of the candidate edit $content: the Content object of the candidate edit $output: the ParserOutput result of the candidate edit +$summary: the change summary of the candidate edit +$user: the User considering the edit 'PasswordPoliciesForUser': Alter the effective password policy for a user. $user: User object whose policy you are modifying diff --git a/includes/api/ApiStashEdit.php b/includes/api/ApiStashEdit.php index dd911d0ff9..08fd2fd4e2 100644 --- a/includes/api/ApiStashEdit.php +++ b/includes/api/ApiStashEdit.php @@ -122,7 +122,7 @@ class ApiStashEdit extends ApiBase { if ( $user->pingLimiter( 'stashedit' ) ) { $status = 'ratelimited'; } elseif ( $dbw->lock( $key, __METHOD__, 1 ) ) { - $status = self::parseAndStash( $page, $content, $user ); + $status = self::parseAndStash( $page, $content, $user, $params['summary'] ); $dbw->unlock( $key, __METHOD__ ); } else { $status = 'busy'; @@ -135,12 +135,13 @@ class ApiStashEdit extends ApiBase { /** * @param WikiPage $page - * @param Content $content + * @param Content $content Edit content * @param User $user + * @param string $summary Edit summary * @return integer ApiStashEdit::ERROR_* constant * @since 1.25 */ - public static function parseAndStash( WikiPage $page, Content $content, User $user ) { + public static function parseAndStash( WikiPage $page, Content $content, User $user, $summary ) { $cache = ObjectCache::getLocalClusterInstance(); $logger = LoggerFactory::getInstance( 'StashEdit' ); @@ -152,7 +153,8 @@ class ApiStashEdit extends ApiBase { $key = self::getStashKey( $title, $content, $user ); // Let extensions add ParserOutput metadata or warm other caches - Hooks::run( 'ParserOutputStashForEdit', [ $page, $content, $editInfo->output ] ); + Hooks::run( 'ParserOutputStashForEdit', + [ $page, $content, $editInfo->output, $summary, $user ] ); list( $stashInfo, $ttl, $code ) = self::buildStashValue( $editInfo->pstContent, @@ -418,6 +420,9 @@ class ApiStashEdit extends ApiBase { ApiBase::PARAM_TYPE => 'text', ApiBase::PARAM_REQUIRED => true ], + 'summary' => [ + ApiBase::PARAM_TYPE => 'string', + ], 'contentmodel' => [ ApiBase::PARAM_TYPE => ContentHandler::getContentModels(), ApiBase::PARAM_REQUIRED => true diff --git a/includes/api/i18n/en.json b/includes/api/i18n/en.json index 82a83496c6..cfd0c74f7a 100644 --- a/includes/api/i18n/en.json +++ b/includes/api/i18n/en.json @@ -1350,6 +1350,7 @@ "apihelp-stashedit-param-contentmodel": "Content model of the new content.", "apihelp-stashedit-param-contentformat": "Content serialization format used for the input text.", "apihelp-stashedit-param-baserevid": "Revision ID of the base revision.", + "apihelp-stashedit-param-summary": "Change summary.", "apihelp-tag-description": "Add or remove change tags from individual revisions or log entries.", "apihelp-tag-param-rcid": "One or more recent changes IDs from which to add or remove the tag.", diff --git a/includes/api/i18n/qqq.json b/includes/api/i18n/qqq.json index 11efd46461..44769cf43a 100644 --- a/includes/api/i18n/qqq.json +++ b/includes/api/i18n/qqq.json @@ -1256,6 +1256,7 @@ "apihelp-stashedit-param-contentmodel": "{{doc-apihelp-param|stashedit|contentmodel}}", "apihelp-stashedit-param-contentformat": "{{doc-apihelp-param|stashedit|contentformat}}", "apihelp-stashedit-param-baserevid": "{{doc-apihelp-param|stashedit|baserevid}}", + "apihelp-stashedit-param-summary": "{{doc-apihelp-param|stashedit|summary}}", "apihelp-tag-description": "{{doc-apihelp-description|tag}}", "apihelp-tag-param-rcid": "{{doc-apihelp-param|tag|rcid}}", "apihelp-tag-param-revid": "{{doc-apihelp-param|tag|revid}}", diff --git a/resources/src/mediawiki.action/mediawiki.action.edit.stash.js b/resources/src/mediawiki.action/mediawiki.action.edit.stash.js index d354fc21f7..2a48ee6439 100644 --- a/resources/src/mediawiki.action/mediawiki.action.edit.stash.js +++ b/resources/src/mediawiki.action/mediawiki.action.edit.stash.js @@ -30,6 +30,7 @@ section: data.wpSection, sectiontitle: '', text: data.wpTextbox1, + summary: data.wpSummary, contentmodel: data.model, contentformat: data.format, baserevid: data.parentRevId -- 2.20.1