Replace TitleMoveCompleting and TitleMoveComplete hooks
Bug: T250023 Change-Id: Iceb0aebb51769c413bf560d1c5b70a7213cb8b91
This commit is contained in:
parent
4e2897575a
commit
1594282ad0
8 changed files with 77 additions and 6 deletions
|
|
@ -857,6 +857,8 @@ because of Phabricator reports.
|
|||
new RevisionUndeleted hook instead.
|
||||
* The NewRevisionFromEditComplete hook has been hard deprecated. Please use
|
||||
the new RevisionFromEditComplete hook instead.
|
||||
* The TitleMoveCompleting and TitleMoveComplete hooks have been soft deprecated.
|
||||
Please use the new PageMoveComplete hook instead.
|
||||
* ResourceLoaderFileModule::compileLessFile() has been deprecated, use
|
||||
ResourceLoaderFileModule::compileLessString() instead
|
||||
* The SquidPurgeClient and SquidPurgeClientPool classes have been deprecated.
|
||||
|
|
|
|||
|
|
@ -2540,6 +2540,15 @@ the key.
|
|||
$user: User (object) requesting the page
|
||||
&$forOptions: array of options the hash is for
|
||||
|
||||
'PageMoveComplete': After moving an article (title), post-commit.
|
||||
$old: LinkTarget for the old title
|
||||
$nt: 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
|
||||
|
||||
'PageViewUpdates': Allow database (or other) changes to be made after a
|
||||
page view is seen by MediaWiki. Note this does not capture views made
|
||||
via external caches such as Squid.
|
||||
|
|
@ -3505,7 +3514,8 @@ $old: old title
|
|||
$nt: new title
|
||||
$user: user who does the move
|
||||
|
||||
'TitleMoveComplete': After moving an article (title), post-commit.
|
||||
'TitleMoveComplete': DEPRECATED since 1.35! Use PageMoveComplete
|
||||
After moving an article (title), post-commit.
|
||||
[&]$old: old title
|
||||
[&]$nt: new title
|
||||
[&]$user: user who did the move
|
||||
|
|
@ -3514,7 +3524,8 @@ $redirid: database ID of the created redirect
|
|||
$reason: reason for the move
|
||||
$revision: the Revision created by the move
|
||||
|
||||
'TitleMoveCompleting': After moving an article (title), pre-commit.
|
||||
'TitleMoveCompleting': DEPRECATED since 1.35! Use PageMoveComplete
|
||||
After moving an article (title), pre-commit.
|
||||
$old: old title
|
||||
$nt: new title
|
||||
$user: user who did the move
|
||||
|
|
|
|||
32
includes/Hook/PageMoveCompleteHook.php
Normal file
32
includes/Hook/PageMoveCompleteHook.php
Normal 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 PageMoveCompleteHook {
|
||||
/**
|
||||
* This hook is called after moving an article (title)
|
||||
*
|
||||
* @since 1.35
|
||||
*
|
||||
* @param LinkTarget $old Old title
|
||||
* @param LinkTarget $nt 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 onPageMoveComplete( $old, $nt, $user, $pageid, $redirid,
|
||||
$reason, $revision
|
||||
);
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ use Title;
|
|||
use User;
|
||||
|
||||
/**
|
||||
* @stable for implementation
|
||||
* @deprecated since 1.35, use the PageMoveComplete hook instead
|
||||
* @ingroup Hooks
|
||||
*/
|
||||
interface TitleMoveCompleteHook {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use Title;
|
|||
use User;
|
||||
|
||||
/**
|
||||
* @stable for implementation
|
||||
* @deprecated since 1.35, use the PageMoveComplete hook instead
|
||||
* @ingroup Hooks
|
||||
*/
|
||||
interface TitleMoveCompletingHook {
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ class DeprecatedHooks {
|
|||
'SpecialMuteSubmit' => [ 'deprecatedVersion' => '1.35', 'silent' => true ],
|
||||
'SkinTemplatePreventOtherActiveTabs' => [ 'deprecatedVersion' => '1.35' ],
|
||||
'SkinTemplateTabAction' => [ 'deprecatedVersion' => '1.35' ],
|
||||
'TitleMoveComplete' => [ 'deprecatedVersion' => '1.35', 'silent' => true ],
|
||||
'TitleMoveCompleting' => [ 'deprecatedVersion' => '1.35', 'silent' => true ],
|
||||
'UndeleteShowRevision' => [ 'deprecatedVersion' => '1.35' ],
|
||||
'UserRetrieveNewTalks' => [ 'deprecatedVersion' => '1.35' ],
|
||||
'UserSetCookies' => [ 'deprecatedVersion' => '1.27' ],
|
||||
|
|
|
|||
|
|
@ -261,6 +261,7 @@ class HookRunner implements
|
|||
\MediaWiki\Hook\PageHistoryLineEndingHook,
|
||||
\MediaWiki\Hook\PageHistoryPager__doBatchLookupsHook,
|
||||
\MediaWiki\Hook\PageHistoryPager__getQueryInfoHook,
|
||||
\MediaWiki\Hook\PageMoveCompleteHook,
|
||||
\MediaWiki\Hook\PageRenderingHashHook,
|
||||
\MediaWiki\Hook\ParserAfterParseHook,
|
||||
\MediaWiki\Hook\ParserAfterStripHook,
|
||||
|
|
@ -2801,6 +2802,13 @@ class HookRunner implements
|
|||
);
|
||||
}
|
||||
|
||||
public function onPageMoveComplete( $old, $new, $user, $pageid, $redirid, $reason, $revision ) {
|
||||
return $this->container->run(
|
||||
'PageMoveComplete',
|
||||
[ $old, $new, $user, $pageid, $redirid, $reason, $revision ]
|
||||
);
|
||||
}
|
||||
|
||||
public function onPageRenderingHash( &$confstr, $user, &$forOptions ) {
|
||||
return $this->container->run(
|
||||
'PageRenderingHash',
|
||||
|
|
|
|||
|
|
@ -694,6 +694,8 @@ class MovePage {
|
|||
}
|
||||
}
|
||||
|
||||
// Deprecated since 1.35, use PageMoveComplete
|
||||
// TODO hard deprecate
|
||||
$nullRevisionObj = new Revision( $nullRevision );
|
||||
$this->hookRunner->onTitleMoveCompleting(
|
||||
$this->oldTitle, $this->newTitle,
|
||||
|
|
@ -706,14 +708,28 @@ class MovePage {
|
|||
new AtomicSectionUpdate(
|
||||
$dbw,
|
||||
__METHOD__,
|
||||
function () use ( $user, $pageid, $redirid, $reason, $nullRevisionObj ) {
|
||||
function () use ( $user, $pageid, $redirid, $reason, $nullRevision ) {
|
||||
$this->hookRunner->onPageMoveComplete(
|
||||
$this->oldTitle,
|
||||
$this->newTitle,
|
||||
$user,
|
||||
$pageid,
|
||||
$redirid,
|
||||
$reason,
|
||||
$nullRevision
|
||||
);
|
||||
|
||||
$nullRevisionObj = new Revision( $nullRevision );
|
||||
// Deprecated since 1.35, use PageMoveComplete
|
||||
// TODO hard deprecate
|
||||
$this->hookRunner->onTitleMoveComplete(
|
||||
$this->oldTitle,
|
||||
$this->newTitle,
|
||||
$user, $pageid,
|
||||
$redirid,
|
||||
$reason,
|
||||
$nullRevisionObj );
|
||||
$nullRevisionObj
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue