Merge "Add PageMoveCompleting hook, to replace TitleMoveCompleting"

This commit is contained in:
jenkins-bot 2020-06-24 02:21:06 +00:00 committed by Gerrit Code Review
commit be8dbab716
6 changed files with 61 additions and 7 deletions

View file

@ -2548,7 +2548,16 @@ $user: User (object) requesting the page
'PageMoveComplete': After moving an article (title), post-commit.
$old: LinkTarget for the old title
$nt: LinkTarget for the new title
$new: LinkTarget for the new title
$user: UserIdentity for the user who did the move
$pageid: database ID of the page that's been moved
$redirid: database ID of the created redirect
$reason: reason for the move
$revisionRecord: the RevisionRecord created by the move
'PageMoveCompleting': After moving an article (title), pre-commit
$old: LinkTarget for the old title
$new: LinkTarget for the new title
$user: UserIdentity for the user who did the move
$pageid: database ID of the page that's been moved
$redirid: database ID of the created redirect
@ -3535,7 +3544,7 @@ $redirid: database ID of the created redirect
$reason: reason for the move
$revision: the Revision created by the move
'TitleMoveCompleting': DEPRECATED since 1.35! Use PageMoveComplete
'TitleMoveCompleting': DEPRECATED since 1.35! Use PageMoveCompleting
After moving an article (title), pre-commit.
$old: old title
$nt: new title

View file

@ -12,12 +12,12 @@ use MediaWiki\User\UserIdentity;
*/
interface PageMoveCompleteHook {
/**
* This hook is called after moving an article (title)
* This hook is called after moving an article (title), post-commit
*
* @since 1.35
*
* @param LinkTarget $old Old title
* @param LinkTarget $nt New title
* @param LinkTarget $new New title
* @param UserIdentity $user User who did the move
* @param int $pageid Database ID of the page that's been moved
* @param int $redirid Database ID of the created redirect
@ -26,7 +26,7 @@ interface PageMoveCompleteHook {
* @return bool|void True or no return value to continue or false stop other hook handlers,
* doesn't abort the move itself
*/
public function onPageMoveComplete( $old, $nt, $user, $pageid, $redirid,
public function onPageMoveComplete( $old, $new, $user, $pageid, $redirid,
$reason, $revision
);
}

View file

@ -0,0 +1,32 @@
<?php
namespace MediaWiki\Hook;
use MediaWiki\Linker\LinkTarget;
use MediaWiki\Revision\RevisionRecord;
use MediaWiki\User\UserIdentity;
/**
* @stable for implementation
* @ingroup Hooks
*/
interface PageMoveCompletingHook {
/**
* This hook is called after moving an article (title), pre-commit
*
* @since 1.35
*
* @param LinkTarget $old Old title
* @param LinkTarget $new New title
* @param UserIdentity $user User who did the move
* @param int $pageid Database ID of the page that's been moved
* @param int $redirid Database ID of the created redirect
* @param string $reason Reason for the move
* @param RevisionRecord $revision Revision created by the move
* @return bool|void True or no return value to continue or false stop other hook handlers,
* doesn't abort the move itself
*/
public function onPageMoveCompleting( $old, $new, $user, $pageid, $redirid,
$reason, $revision
);
}

View file

@ -7,7 +7,7 @@ use Title;
use User;
/**
* @deprecated since 1.35, use the PageMoveComplete hook instead
* @deprecated since 1.35, use the PageMoveCompleting hook instead
* @ingroup Hooks
*/
interface TitleMoveCompletingHook {

View file

@ -264,6 +264,7 @@ class HookRunner implements
\MediaWiki\Hook\PageHistoryPager__doBatchLookupsHook,
\MediaWiki\Hook\PageHistoryPager__getQueryInfoHook,
\MediaWiki\Hook\PageMoveCompleteHook,
\MediaWiki\Hook\PageMoveCompletingHook,
\MediaWiki\Hook\PageRenderingHashHook,
\MediaWiki\Hook\ParserAfterParseHook,
\MediaWiki\Hook\ParserAfterStripHook,
@ -2842,6 +2843,13 @@ class HookRunner implements
);
}
public function onPageMoveCompleting( $old, $new, $user, $pageid, $redirid, $reason, $revision ) {
return $this->container->run(
'PageMoveCompleting',
[ $old, $new, $user, $pageid, $redirid, $reason, $revision ]
);
}
public function onPageRenderingHash( &$confstr, $user, &$forOptions ) {
return $this->container->run(
'PageRenderingHash',

View file

@ -694,7 +694,12 @@ class MovePage {
}
}
// Deprecated since 1.35, use PageMoveComplete
$this->hookRunner->onPageMoveCompleting(
$this->oldTitle, $this->newTitle,
$user, $pageid, $redirid, $reason, $nullRevision
);
// Deprecated since 1.35, use PageMoveCompleting
// TODO hard deprecate
$nullRevisionObj = new Revision( $nullRevision );
$this->hookRunner->onTitleMoveCompleting(