Pass undone revision id to PageContentSaveComplete hook
authorcenarium <cenarium.sysop@gmail.com>
Sun, 18 Dec 2016 02:06:42 +0000 (03:06 +0100)
committercenarium <cenarium.sysop@gmail.com>
Mon, 19 Dec 2016 16:19:39 +0000 (17:19 +0100)
This passes the id of the revision that was undone to the
PageContentSaveComplete hook, since this hook is now inside a deferred
update so extensions can no longer rely on 'wpUndidRevision' being
present in the request.

Change-Id: I50dcb841cd0616acc2d69c3a685ba3cb339986c3

docs/hooks.txt
includes/EditPage.php
includes/page/WikiPage.php

index 1ecc1f8..1b543b5 100644 (file)
@@ -759,6 +759,7 @@ $flags: Flags passed to WikiPage::doEditContent()
 $revision: New Revision of the article
 $status: Status object about to be returned by doEditContent()
 $baseRevId: the rev ID (or false) this edit was based on
+$undidRevId: the rev ID (or 0) this edit undid
 
 'ArticleUndelete': When one or more revisions of an article are restored.
 &$title: Title corresponding to the article restored
@@ -2385,6 +2386,7 @@ $revision: New Revision of the article (can be null for edits that change
   nothing)
 $status: Status object about to be returned by doEditContent()
 $baseRevId: the rev ID (or false) this edit was based on
+$undidRevId: the rev ID (or 0) this edit undid
 
 'PageHistoryBeforeList': When a history page list is about to be constructed.
 &$article: the article that the history is loading for
index 4f1e47d..1f871e1 100644 (file)
@@ -2146,7 +2146,8 @@ class EditPage {
                        false,
                        $wgUser,
                        $content->getDefaultFormat(),
-                       $this->changeTags
+                       $this->changeTags,
+                       $this->undidRev
                );
 
                if ( !$doEditStatus->isOK() ) {
index 071cee7..45540b5 100644 (file)
@@ -1598,6 +1598,7 @@ class WikiPage implements Page, IDBAccessObject {
         * @param array|null $tags Change tags to apply to this edit
         * Callers are responsible for permission checks
         * (with ChangeTags::canAddTagsAccompanyingChange)
+        * @param Int $undidRevId Id of revision that was undone or 0
         *
         * @throws MWException
         * @return Status Possible errors:
@@ -1619,7 +1620,7 @@ class WikiPage implements Page, IDBAccessObject {
         */
        public function doEditContent(
                Content $content, $summary, $flags = 0, $baseRevId = false,
-               User $user = null, $serialFormat = null, $tags = []
+               User $user = null, $serialFormat = null, $tags = [], $undidRevId = 0
        ) {
                global $wgUser, $wgUseAutomaticEditSummaries;
 
@@ -1698,7 +1699,8 @@ class WikiPage implements Page, IDBAccessObject {
                        'oldId' => $this->getLatest(),
                        'oldIsRedirect' => $this->isRedirect(),
                        'oldCountable' => $this->isCountable(),
-                       'tags' => ( $tags !== null ) ? (array)$tags : []
+                       'tags' => ( $tags !== null ) ? (array)$tags : [],
+                       'undidRevId' => $undidRevId
                ];
 
                // Actually create the revision and create/update the page
@@ -1878,7 +1880,8 @@ class WikiPage implements Page, IDBAccessObject {
                                        );
                                        // Trigger post-save hook
                                        $params = [ &$this, &$user, $content, $summary, $flags & EDIT_MINOR,
-                                               null, null, &$flags, $revision, &$status, $meta['baseRevId'] ];
+                                               null, null, &$flags, $revision, &$status, $meta['baseRevId'],
+                                               $meta['undidRevId'] ];
                                        ContentHandler::runLegacyHooks( 'ArticleSaveComplete', $params );
                                        Hooks::run( 'PageContentSaveComplete', $params );
                                }