Send the edit summary/user to the edit stash API
authorAaron Schulz <aschulz@wikimedia.org>
Mon, 13 Jun 2016 10:09:45 +0000 (03:09 -0700)
committerOri.livneh <ori@wikimedia.org>
Mon, 13 Jun 2016 22:40:50 +0000 (22:40 +0000)
This can be useful for pre-caching AbuseFilter check results

Bug: T137698
Change-Id: I03e3924408a2a5da09a411b66d09958a1b78cb99

docs/hooks.txt
includes/api/ApiStashEdit.php
includes/api/i18n/en.json
includes/api/i18n/qqq.json
resources/src/mediawiki.action/mediawiki.action.edit.stash.js

index e0b91f2..5c69d2a 100644 (file)
@@ -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
index dd911d0..08fd2fd 100644 (file)
@@ -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
index 82a8349..cfd0c74 100644 (file)
        "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.",
index 11efd46..44769cf 100644 (file)
        "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}}",
index d354fc2..2a48ee6 100644 (file)
@@ -30,6 +30,7 @@
                                        section: data.wpSection,
                                        sectiontitle: '',
                                        text: data.wpTextbox1,
+                                       summary: data.wpSummary,
                                        contentmodel: data.model,
                                        contentformat: data.format,
                                        baserevid: data.parentRevId