From: cenarium Date: Sun, 18 Dec 2016 02:06:42 +0000 (+0100) Subject: Pass undone revision id to PageContentSaveComplete hook X-Git-Tag: 1.31.0-rc.0~4509^2 X-Git-Url: https://git.heureux-cyclage.org/?a=commitdiff_plain;h=7d7f8e2ae25c4be411d015e6ddb5992f3a56e931;p=lhc%2Fweb%2Fwiklou.git Pass undone revision id to PageContentSaveComplete hook 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 --- diff --git a/docs/hooks.txt b/docs/hooks.txt index 1ecc1f82d8..1b543b50e9 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -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 diff --git a/includes/EditPage.php b/includes/EditPage.php index 4f1e47d63b..1f871e1941 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -2146,7 +2146,8 @@ class EditPage { false, $wgUser, $content->getDefaultFormat(), - $this->changeTags + $this->changeTags, + $this->undidRev ); if ( !$doEditStatus->isOK() ) { diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index 071cee7eb3..45540b5819 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -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 ); }