Add HistoryTools and DiffTools hooks
Bug: T255494 Bug: T255495 Change-Id: Ib2ab2e26a95affdd1dfa6b945f752157580ea2d3
This commit is contained in:
parent
dce1805249
commit
5abd50b925
10 changed files with 92 additions and 4 deletions
|
|
@ -1057,6 +1057,8 @@ because of Phabricator reports.
|
|||
well as suitable replacements, are noted below:
|
||||
- ArticleRevisionUndeleted (hard deprecated, use the RevisionUndeleted hook)
|
||||
- ArticleRollbackComplete (hard deprecated, use the RollbackComplete hook)
|
||||
- DiffRevisionTools (soft deprecated, use the DiffTools hook)
|
||||
- HistoryRevisionTools (soft deprecated, use the HistoryTools hook)
|
||||
- NewRevisionFromEditComplete (hard deprecated, use the
|
||||
RevisionFromEditComplete hook).
|
||||
- PageContentInsertComplete (soft deprecated, use the PageSaveComplete hook)
|
||||
|
|
|
|||
|
|
@ -918,6 +918,7 @@ $wgAutoloadLocalClasses = [
|
|||
'MediaWiki\\Hook\\GetNewMessagesAlertHook' => __DIR__ . '/includes/skins/Hook/GetNewMessagesAlertHook.php',
|
||||
'MediaWiki\\Hook\\HistoryPageToolLinksHook' => __DIR__ . '/includes/actions/Hook/HistoryPageToolLinksHook.php',
|
||||
'MediaWiki\\Hook\\HistoryRevisionToolsHook' => __DIR__ . '/includes/actions/Hook/HistoryRevisionToolsHook.php',
|
||||
'MediaWiki\\Hook\\HistoryToolsHook' => __DIR__ . '/includes/actions/Hook/HistoryToolsHook.php',
|
||||
'MediaWiki\\Hook\\IRCLineURLHook' => __DIR__ . '/includes/rcfeed/Hook/IRCLineURLHook.php',
|
||||
'MediaWiki\\Hook\\ImportHandleLogItemXMLTagHook' => __DIR__ . '/includes/import/Hook/ImportHandleLogItemXMLTagHook.php',
|
||||
'MediaWiki\\Hook\\ImportHandlePageXMLTagHook' => __DIR__ . '/includes/import/Hook/ImportHandlePageXMLTagHook.php',
|
||||
|
|
|
|||
|
|
@ -47,7 +47,9 @@ class DeprecatedHooks {
|
|||
'BaseTemplateAfterPortlet' => [ 'deprecatedVersion' => '1.35', 'silent' => true ],
|
||||
'BaseTemplateToolbox' => [ 'deprecatedVersion' => '1.35' ],
|
||||
'BeforeParserrenderImageGallery' => [ 'deprecatedVersion' => '1.35' ],
|
||||
'DiffRevisionTools' => [ 'deprecatedVersion => 1.35', 'silent' => true ],
|
||||
'DiffViewHeader' => [ 'deprecatedVersion' => '1.35', 'silent' => true ],
|
||||
'HistoryRevisionTools' => [ 'deprecatedVersion => 1.35', 'silent' => true ],
|
||||
'InternalParseBeforeSanitize' => [ 'deprecatedVersion' => '1.35' ],
|
||||
'LinkBegin' => [ 'deprecatedVersion' => '1.28' ],
|
||||
'LinkEnd' => [ 'deprecatedVersion' => '1.28' ],
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ class HookRunner implements
|
|||
\MediaWiki\Diff\Hook\DifferenceEngineShowEmptyOldContentHook,
|
||||
\MediaWiki\Diff\Hook\DifferenceEngineViewHeaderHook,
|
||||
\MediaWiki\Diff\Hook\DiffRevisionToolsHook,
|
||||
\MediaWiki\Diff\Hook\DiffToolsHook,
|
||||
\MediaWiki\Diff\Hook\DiffViewHeaderHook,
|
||||
\MediaWiki\Diff\Hook\NewDifferenceEngineHook,
|
||||
\MediaWiki\Hook\AbortEmailNotificationHook,
|
||||
|
|
@ -188,6 +189,7 @@ class HookRunner implements
|
|||
\MediaWiki\Hook\GitViewersHook,
|
||||
\MediaWiki\Hook\HistoryPageToolLinksHook,
|
||||
\MediaWiki\Hook\HistoryRevisionToolsHook,
|
||||
\MediaWiki\Hook\HistoryToolsHook,
|
||||
\MediaWiki\Hook\ImageBeforeProduceHTMLHook,
|
||||
\MediaWiki\Hook\ImgAuthBeforeStreamHook,
|
||||
\MediaWiki\Hook\ImgAuthModifyHeadersHook,
|
||||
|
|
@ -1495,6 +1497,13 @@ class HookRunner implements
|
|||
);
|
||||
}
|
||||
|
||||
public function onDiffTools( $newRevRecord, &$links, $oldRevRecord, $userIdentity ) {
|
||||
return $this->container->run(
|
||||
'DiffTools',
|
||||
[ $newRevRecord, &$links, $oldRevRecord, $userIdentity ]
|
||||
);
|
||||
}
|
||||
|
||||
public function onDiffViewHeader( $diff, $oldRev, $newRev ) {
|
||||
return $this->container->run(
|
||||
'DiffViewHeader',
|
||||
|
|
@ -2016,6 +2025,13 @@ class HookRunner implements
|
|||
);
|
||||
}
|
||||
|
||||
public function onHistoryTools( $revRecord, &$links, $prevRevRecord, $userIdentity ) {
|
||||
return $this->container->run(
|
||||
'HistoryTools',
|
||||
[ $revRecord, &$links, $prevRevRecord, $userIdentity ]
|
||||
);
|
||||
}
|
||||
|
||||
public function onHtmlCacheUpdaterAppendUrls( $title, $mode, &$append ) {
|
||||
return $this->container->run(
|
||||
'HtmlCacheUpdaterAppendUrls',
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use Revision;
|
|||
use User;
|
||||
|
||||
/**
|
||||
* @stable for implementation
|
||||
* @deprecated since 1.35
|
||||
* @ingroup Hooks
|
||||
*/
|
||||
interface HistoryRevisionToolsHook {
|
||||
|
|
|
|||
27
includes/actions/Hook/HistoryToolsHook.php
Normal file
27
includes/actions/Hook/HistoryToolsHook.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Hook;
|
||||
|
||||
use MediaWiki\Revision\RevisionRecord;
|
||||
use MediaWiki\User\UserIdentity;
|
||||
|
||||
/**
|
||||
* @stable for implementation
|
||||
* @ingroup Hooks
|
||||
*/
|
||||
interface HistoryToolsHook {
|
||||
/**
|
||||
* Use this hook to override or extend the revision tools available from the
|
||||
* page history view, i.e. undo, rollback, etc.
|
||||
*
|
||||
* @since 1.35
|
||||
*
|
||||
* @param RevisionRecord $revRecord
|
||||
* @param string[] &$links Array of HTML links
|
||||
* @param RevisionRecord|null $prevRevRecord RevisionRecord object, next in line
|
||||
* in page history, or null
|
||||
* @param UserIdentity $userIdentity Current user
|
||||
* @return bool|void True or no return value to continue or false to abort
|
||||
*/
|
||||
public function onHistoryTools( $revRecord, &$links, $prevRevRecord, $userIdentity );
|
||||
}
|
||||
|
|
@ -479,7 +479,14 @@ class HistoryPager extends ReverseChronologicalPager {
|
|||
}
|
||||
}
|
||||
// Allow extension to add their own links here
|
||||
// TODO replace hook with one using RevisionRecord
|
||||
$this->getHookRunner()->onHistoryTools(
|
||||
$revRecord,
|
||||
$tools,
|
||||
$previousRevRecord,
|
||||
$user
|
||||
);
|
||||
|
||||
// Deprecated since 1.35
|
||||
$this->getHookRunner()->onHistoryRevisionTools(
|
||||
new Revision( $revRecord ),
|
||||
$tools,
|
||||
|
|
|
|||
|
|
@ -775,7 +775,14 @@ class DifferenceEngine extends ContextSource {
|
|||
$rdel = $this->revisionDeleteLink( $this->mNewRevisionRecord );
|
||||
|
||||
# Allow extensions to define their own revision tools
|
||||
# TODO use RevisionRecord
|
||||
$this->hookRunner->onDiffTools(
|
||||
$this->mOldRevisionRecord,
|
||||
$revisionTools,
|
||||
$this->mNewRevisionRecord,
|
||||
$user
|
||||
);
|
||||
|
||||
# Hook deprecated since 1.35
|
||||
$legacyOldRev = $this->mOldRevisionRecord ?
|
||||
new Revision( $this->mOldRevisionRecord ) :
|
||||
null;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use Revision;
|
|||
use User;
|
||||
|
||||
/**
|
||||
* @stable for implementation
|
||||
* @deprecated since 1.35
|
||||
* @ingroup Hooks
|
||||
*/
|
||||
interface DiffRevisionToolsHook {
|
||||
|
|
|
|||
26
includes/diff/Hook/DiffToolsHook.php
Normal file
26
includes/diff/Hook/DiffToolsHook.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Diff\Hook;
|
||||
|
||||
use MediaWiki\Revision\RevisionRecord;
|
||||
use MediaWiki\User\UserIdentity;
|
||||
|
||||
/**
|
||||
* @stable for implementation
|
||||
* @ingroup Hooks
|
||||
*/
|
||||
interface DiffToolsHook {
|
||||
/**
|
||||
* Use this hook to override or extend the revision tools available from the
|
||||
* diff view, i.e. undo, etc.
|
||||
*
|
||||
* @since 1.35
|
||||
*
|
||||
* @param RevisionRecord $newRevRecord New revision
|
||||
* @param string[] &$links Array of HTML links
|
||||
* @param RevisionRecord|null $oldRevRecord Old revision (may be null)
|
||||
* @param UserIdentity $userIdentity Current user
|
||||
* @return bool|void True or no return value to continue or false to abort
|
||||
*/
|
||||
public function onDiffTools( $newRevRecord, &$links, $oldRevRecord, $userIdentity );
|
||||
}
|
||||
Loading…
Reference in a new issue