aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUmherirrender <umherirrender_de.wp@web.de>2023-05-06 23:23:07 +0200
committerUmherirrender <umherirrender_de.wp@web.de>2023-05-18 18:39:17 +0000
commitf452ffe9a1ae66704d50118b67c98356b4cc449e (patch)
tree95360c5dba88be9c420b5a08de388d73f17bfa33
parentbacc43aa5ea569d47ccb54e3b3ed973d3bd4aa27 (diff)
downloadmediawikicore-f452ffe9a1ae66704d50118b67c98356b4cc449e.tar.gz
mediawikicore-f452ffe9a1ae66704d50118b67c98356b4cc449e.zip
Hard-deprecate Hooks::isRegistered/getHandlers/run/runWithoutAbort
- Hooks::isRegistered - Hooks::getHandlers - Hooks::run - Hooks::runWithoutAbort - Hooks::runner (is internal and not mention in release notes) Bug: T335536 Change-Id: I498c79c57091caca40c4cc649f2f05ed6a7f7700
-rw-r--r--RELEASE-NOTES-1.412
-rw-r--r--includes/Hooks.php16
-rw-r--r--tests/phpunit/includes/HooksTest.php12
3 files changed, 25 insertions, 5 deletions
diff --git a/RELEASE-NOTES-1.41 b/RELEASE-NOTES-1.41
index b47b2140c1bf..cec306a4829a 100644
--- a/RELEASE-NOTES-1.41
+++ b/RELEASE-NOTES-1.41
@@ -232,6 +232,8 @@ because of Phabricator reports.
* UserGroupMembership::getGroupName(), deprecated in 1.38, and
UserGroupMembership::getGroupMemberName(), deprecated in 1.40, now emit
deprecation warnings.
+* Hooks::isRegistered(), ::getHandlers(), ::run() and ::runWithoutAbort(),
+ deprecated in 1.35, now emit deprecation warnings.
* …
=== Other changes in 1.41 ===
diff --git a/includes/Hooks.php b/includes/Hooks.php
index a6844d5fa20e..763e43e8aea6 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -61,7 +61,7 @@ class Hooks {
*
* @since 1.21
* @deprecated since 1.35. Instead of using Hooks::register() and Hooks::clear(),
- * use HookContainer::scopedRegister() instead to register a temporary hook
+ * use HookContainer::scopedRegister() instead to register a temporary hook, emitting warnings since 1.35
* @codeCoverageIgnore
*/
public static function clear( $name ) {
@@ -78,11 +78,12 @@ class Hooks {
* The function may have been registered either via Hooks::register or in $wgHooks.
*
* @since 1.18
- * @deprecated since 1.35. use HookContainer::isRegistered() instead
+ * @deprecated since 1.35. use HookContainer::isRegistered() instead, emitting warnings since 1.41
* @param string $name Name of hook
* @return bool True if the hook has a function registered to it
*/
public static function isRegistered( $name ) {
+ wfDeprecated( __METHOD__, '1.35' );
$hookContainer = MediaWikiServices::getInstance()->getHookContainer();
return $hookContainer->isRegistered( $name );
}
@@ -92,11 +93,12 @@ class Hooks {
* This combines functions registered via Hooks::register and with $wgHooks.
*
* @since 1.18
- * @deprecated since 1.35
+ * @deprecated since 1.35, emitting warnings since 1.41
* @param string $name Name of the hook
* @return array
*/
public static function getHandlers( $name ) {
+ wfDeprecated( __METHOD__, '1.35' );
$hookContainer = MediaWikiServices::getInstance()->getHookContainer();
$handlers = $hookContainer->getLegacyHandlers( $name );
$funcName = 'on' . strtr( ucfirst( $name ), ':-', '__' );
@@ -126,9 +128,10 @@ class Hooks {
* @since 1.22 A hook function is not required to return a value for
* processing to continue. Not returning a value (or explicitly
* returning null) is equivalent to returning true.
- * @deprecated since 1.35 Use HookContainer::run() instead
+ * @deprecated since 1.35 Use HookContainer::run() instead, emitting warnings since 1.41
*/
public static function run( $event, array $args = [], $deprecatedVersion = null ) {
+ wfDeprecated( __METHOD__, '1.35' );
$hookContainer = MediaWikiServices::getInstance()->getHookContainer();
$options = $deprecatedVersion ? [ 'deprecatedVersion' => $deprecatedVersion ] : [];
return $hookContainer->run( $event, $args, $options );
@@ -143,9 +146,10 @@ class Hooks {
* @return bool Always true
* @throws UnexpectedValueException callback returns an invalid value
* @since 1.30
- * @deprecated since 1.35 Use HookContainer::run() with 'abortable' option instead
+ * @deprecated since 1.35 Use HookContainer::run() with 'abortable' option instead, emitting warnings since 1.41
*/
public static function runWithoutAbort( $event, array $args = [], $deprecatedVersion = null ) {
+ wfDeprecated( __METHOD__, '1.35' );
$hookContainer = MediaWikiServices::getInstance()->getHookContainer();
$options = $deprecatedVersion ? [ 'deprecatedVersion' => $deprecatedVersion ] : [];
$options[ 'abortable' ] = false;
@@ -164,10 +168,12 @@ class Hooks {
*
* @since 1.35
* @internal because HookRunner is intended for core only, see documentation on that class
+ * @deprecated since 1.41, emitting warnings since 1.41
*
* @return HookRunner
*/
public static function runner() {
+ wfDeprecated( __METHOD__, '1.41' );
return new HookRunner( MediaWikiServices::getInstance()->getHookContainer() );
}
}
diff --git a/tests/phpunit/includes/HooksTest.php b/tests/phpunit/includes/HooksTest.php
index ec32e61ff5d5..5bdb18011827 100644
--- a/tests/phpunit/includes/HooksTest.php
+++ b/tests/phpunit/includes/HooksTest.php
@@ -59,6 +59,7 @@ class HooksTest extends MediaWikiIntegrationTestCase {
* @covers Hooks::run
*/
public function testRunningNewStyleHooks( $msg, $hook, $expectedFoo, $expectedBar ) {
+ $this->hideDeprecated( 'Hooks::run' );
$foo = $bar = 'original';
$hookContainer = $this->getServiceContainer()->getHookContainer();
$hookContainer->register( self::MOCK_HOOK_NAME, $hook );
@@ -75,6 +76,9 @@ class HooksTest extends MediaWikiIntegrationTestCase {
* @covers Hooks::run
*/
public function testRegistration() {
+ $this->hideDeprecated( 'Hooks::isRegistered' );
+ $this->hideDeprecated( 'Hooks::getHandlers' );
+ $this->hideDeprecated( 'Hooks::run' );
global $wgHooks;
$hookContainer = $this->getServiceContainer()->getHookContainer();
@@ -117,6 +121,7 @@ class HooksTest extends MediaWikiIntegrationTestCase {
* @covers Hooks::run
*/
public function testUncallableFunction() {
+ $this->hideDeprecated( 'Hooks::run' );
$hookContainer = $this->getServiceContainer()->getHookContainer();
$hookContainer->register( self::MOCK_HOOK_NAME, 'ThisFunctionDoesntExist' );
$this->expectExceptionMessage( 'Call to undefined function ThisFunctionDoesntExist' );
@@ -127,6 +132,7 @@ class HooksTest extends MediaWikiIntegrationTestCase {
* @covers Hooks::run
*/
public function testFalseReturn() {
+ $this->hideDeprecated( 'Hooks::run' );
$hookContainer = $this->getServiceContainer()->getHookContainer();
$hookContainer->register( self::MOCK_HOOK_NAME, static function ( &$foo ) {
return false;
@@ -144,6 +150,7 @@ class HooksTest extends MediaWikiIntegrationTestCase {
* @covers Hooks::run
*/
public function testNullReturn() {
+ $this->hideDeprecated( 'Hooks::run' );
$hookContainer = $this->getServiceContainer()->getHookContainer();
$hookContainer->register( self::MOCK_HOOK_NAME, static function ( &$foo ) {
return;
@@ -162,6 +169,7 @@ class HooksTest extends MediaWikiIntegrationTestCase {
* @covers Hooks::run
*/
public function testCallHook_FalseHook() {
+ $this->hideDeprecated( 'Hooks::run' );
$hookContainer = $this->getServiceContainer()->getHookContainer();
$hookContainer->register( self::MOCK_HOOK_NAME, false );
$hookContainer->register( self::MOCK_HOOK_NAME, static function ( &$foo ) {
@@ -178,6 +186,7 @@ class HooksTest extends MediaWikiIntegrationTestCase {
* @covers Hooks::run
*/
public function testCallHook_UnknownDatatype() {
+ $this->hideDeprecated( 'Hooks::run' );
$hookContainer = $this->getServiceContainer()->getHookContainer();
$hookContainer->register( self::MOCK_HOOK_NAME, 12345 );
$this->expectException( UnexpectedValueException::class );
@@ -200,6 +209,7 @@ class HooksTest extends MediaWikiIntegrationTestCase {
* @covers Hooks::runWithoutAbort
*/
public function testRunWithoutAbort() {
+ $this->hideDeprecated( 'Hooks::runWithoutAbort' );
$list = [];
$hookContainer = $this->getServiceContainer()->getHookContainer();
$hookContainer->register( self::MOCK_HOOK_NAME, static function ( &$list ) {
@@ -223,6 +233,7 @@ class HooksTest extends MediaWikiIntegrationTestCase {
* @covers Hooks::runWithoutAbort
*/
public function testRunWithoutAbortWarning() {
+ $this->hideDeprecated( 'Hooks::runWithoutAbort' );
$hookContainer = $this->getServiceContainer()->getHookContainer();
$hookContainer->register( self::MOCK_HOOK_NAME, static function ( &$foo ) {
return false;
@@ -244,6 +255,7 @@ class HooksTest extends MediaWikiIntegrationTestCase {
* @covers Hooks::run
*/
public function testBadHookFunction() {
+ $this->hideDeprecated( 'Hooks::run' );
$hookContainer = $this->getServiceContainer()->getHookContainer();
$hookContainer->register( self::MOCK_HOOK_NAME, static function () {
return 'test';