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
This commit is contained in:
cenarium 2016-12-18 03:06:42 +01:00
parent 4fc7420fea
commit 7d7f8e2ae2
3 changed files with 10 additions and 4 deletions

View 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

View file

@ -2146,7 +2146,8 @@ class EditPage {
false,
$wgUser,
$content->getDefaultFormat(),
$this->changeTags
$this->changeTags,
$this->undidRev
);
if ( !$doEditStatus->isOK() ) {

View 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 );
}