From d459add63d1992723bbdb89ee08a82aa1cc2b8ea Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Fri, 12 Jun 2020 14:18:35 +1000 Subject: [PATCH] Introduce wfDeprecatedMsg() Deprecating something means to say something nasty about it, or to draw its character into question. For example, "this function is lazy and good for nothing". Deprecatory remarks by a developer are generally taken as a warning that violence will soon be done against the function in question. Other developers are thus warned to avoid associating with the deprecated function. However, since wfDeprecated() was introduced, it has become obvious that the targets of deprecation are not limited to functions. Developers can deprecate literally anything: a parameter, a return value, a file format, Mondays, the concept of being, etc. wfDeprecated() requires every deprecatory statement to begin with "use of", leading to some awkward sentences. For example, one might say: "Use of your mouth to cough without it being covered by your arm is deprecated since 2020." So, introduce wfDeprecatedMsg(), which allows deprecation messages to be specified in plain text, with the caller description being optionally appended. Migrate incorrect or gramatically awkward uses of wfDeprecated() to wfDeprecatedMsg(). Change-Id: Ib3dd2fe37677d98425d0f3692db5c9e988943ae8 --- includes/FileDeleteForm.php | 5 +- includes/GlobalFunctions.php | 26 +++++++++ includes/HookContainer/HookContainer.php | 7 ++- includes/Hooks.php | 5 +- includes/MergeHistory.php | 3 +- includes/OutputPage.php | 4 +- includes/Title.php | 6 +- includes/api/ApiQuerySearch.php | 5 +- includes/changes/CategoryMembershipChange.php | 5 +- includes/db/MWLBFactory.php | 7 ++- includes/debug/MWDebug.php | 58 +++++++++++++++---- .../filerepo/file/LocalFileDeleteBatch.php | 8 +-- includes/htmlform/fields/HTMLInfoField.php | 5 +- .../virtualrest/ParsoidVirtualRESTService.php | 5 +- includes/page/Article.php | 6 +- includes/parser/Parser.php | 11 ++-- includes/parser/ParserOptions.php | 2 +- includes/parser/Sanitizer.php | 3 +- includes/registration/ExtensionRegistry.php | 7 ++- .../search/searchwidgets/DidYouMeanWidget.php | 14 +++-- includes/specialpage/SpecialPageFactory.php | 7 ++- includes/specials/SpecialContributions.php | 6 +- includes/specials/SpecialEmailUser.php | 4 +- includes/specials/SpecialSearch.php | 5 +- includes/title/NamespaceInfo.php | 3 +- includes/user/PasswordReset.php | 6 +- includes/user/User.php | 7 ++- languages/Language.php | 8 ++- tests/parser/TestFileReader.php | 31 +++++++--- tests/phpunit/includes/MergeHistoryTest.php | 4 +- tests/phpunit/includes/OutputPageTest.php | 2 +- tests/phpunit/includes/db/MWLBFactoryTest.php | 2 +- tests/phpunit/includes/page/ArticleTest.php | 14 ++--- .../includes/title/NamespaceInfoTest.php | 2 +- 34 files changed, 199 insertions(+), 94 deletions(-) diff --git a/includes/FileDeleteForm.php b/includes/FileDeleteForm.php index 3fd2dd84f0e..9e7df89fb25 100644 --- a/includes/FileDeleteForm.php +++ b/includes/FileDeleteForm.php @@ -67,8 +67,9 @@ class FileDeleteForm { $this->file = $file; if ( $user === null ) { - wfDeprecated( - __CLASS__ . ' being constructing without a $user parameter', + wfDeprecatedMsg( + 'Construction of ' . __CLASS__ . ' without a $user parameter ' . + 'was deprecated in MediaWiki 1.35', '1.35' ); global $wgUser; diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index a77c61c1bc1..9b890a5fa3f 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1037,6 +1037,32 @@ function wfDeprecated( $function, $version = false, $component = false, $callerO } } +/** + * Log a deprecation warning with arbitrary message text. A caller + * description will be appended. If the message has already been sent for + * this caller, it won't be sent again. + * + * Although there are component and version parameters, they are not + * automatically appended to the message. The message text should include + * information about when the thing was deprecated. The component and version + * are just used to implement $wgDeprecationReleaseLimit. + * + * @since 1.35 + * + * @param string $msg The message + * @param string|false $version Version of MediaWiki that the function + * was deprecated in. + * @param string|bool $component Component to which the function belongs. + * If false, it is assumed the function is in MediaWiki core. + * @param int|false $callerOffset How far up the call stack is the original + * caller. 2 = function that called the function that called us. If false, + * the caller description will not be appended. + */ +function wfDeprecatedMsg( $msg, $version = false, $component = false, $callerOffset = 2 ) { + MWDebug::deprecatedMsg( $msg, $version, $component, + $callerOffset === false ? false : $callerOffset + 1 ); +} + /** * Send a warning either to the debug log or in a PHP error depending on * $wgDevelopmentWarnings. To log warnings in production, use wfLogWarning() instead. diff --git a/includes/HookContainer/HookContainer.php b/includes/HookContainer/HookContainer.php index 61df86d2a34..f9cd9e619c4 100644 --- a/includes/HookContainer/HookContainer.php +++ b/includes/HookContainer/HookContainer.php @@ -137,9 +137,10 @@ class HookContainer implements SalvageableService { return false; } if ( is_string( $return ) ) { - wfDeprecated( - "returning a string from a hook handler (done by $functionName for $hook)", - '1.35' + wfDeprecatedMsg( + "Returning a string from a hook handler is deprecated since MediaWiki 1.35 ' . + '(done by $functionName for $hook)", + '1.35', false, false ); throw new UnexpectedValueException( $return ); } diff --git a/includes/Hooks.php b/includes/Hooks.php index 714d171e2dd..65ee11f2946 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -47,8 +47,9 @@ class Hooks { */ public static function register( $name, $callback ) { if ( !defined( 'MW_SERVICE_BOOTSTRAP_COMPLETE' ) ) { - wfDeprecated( 'Registering handler for ' . $name . - ' before MediaWiki bootstrap complete', '1.35' ); + wfDeprecatedMsg( 'Registering handler for ' . $name . + ' before MediaWiki bootstrap complete was deprecated in MediaWiki 1.35', + '1.35' ); } $hookContainer = MediaWikiServices::getInstance()->getHookContainer(); $hookContainer->register( $name, $callback ); diff --git a/includes/MergeHistory.php b/includes/MergeHistory.php index b0cced05170..bcd902d7226 100644 --- a/includes/MergeHistory.php +++ b/includes/MergeHistory.php @@ -105,7 +105,8 @@ class MergeHistory { SpamChecker $spamChecker = null ) { if ( $loadBalancer === null ) { - wfDeprecated( __CLASS__ . ' being constructed directly', '1.35' ); + wfDeprecatedMsg( 'Direct construction of ' . __CLASS__ . + ' was deprecated in MediaWiki 1.35', '1.35' ); $services = MediaWikiServices::getInstance(); $loadBalancer = $services->getDBLoadBalancer(); diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 0b8573fda55..82669ee6cd5 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -2265,7 +2265,9 @@ class OutputPage extends ContextSource { */ public function addVaryHeader( $header, array $option = null ) { if ( $option !== null && count( $option ) > 0 ) { - wfDeprecated( 'addVaryHeader $option is ignored', '1.34' ); + wfDeprecatedMsg( + 'The $option parameter to addVaryHeader is ignored since MediaWiki 1.34', + '1.34' ); } if ( !array_key_exists( $header, $this->mVaryHeader ) ) { $this->mVaryHeader[$header] = null; diff --git a/includes/Title.php b/includes/Title.php index b82d0ab6519..fe9138e10c0 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -2060,9 +2060,9 @@ class Title implements LinkTarget, IDBAccessObject { */ private static function fixUrlQueryArgs( $query, $query2 = false ) { if ( $query2 !== false ) { - wfDeprecated( "Title::get{Canonical,Full,Link,Local,Internal}URL " . - "method called with a second parameter is deprecated. Add your " . - "parameter to an array passed as the first parameter.", "1.19" ); + wfDeprecatedMsg( "Title::get{Canonical,Full,Link,Local,Internal}URL " . + "method called with a second parameter is deprecated since MediaWiki 1.19. " . + "Add your parameter to an array passed as the first parameter.", "1.19" ); } if ( is_array( $query ) ) { $query = wfArrayToCgi( $query ); diff --git a/includes/api/ApiQuerySearch.php b/includes/api/ApiQuerySearch.php index 20878153c7b..2670edf1d0c 100644 --- a/includes/api/ApiQuerySearch.php +++ b/includes/api/ApiQuerySearch.php @@ -68,8 +68,9 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { $nquery = $search->replacePrefixes( $query ); if ( $nquery !== $query ) { $query = $nquery; - wfDeprecated( 'SearchEngine::replacePrefixes() (overridden by ' . - get_class( $search ) . ')', '1.32' ); + wfDeprecatedMsg( 'SearchEngine::replacePrefixes() is overridden by ' . + get_class( $search ) . ', this was deprecated in MediaWiki 1.32', + '1.32' ); } // Perform the actual search if ( $what == 'text' ) { diff --git a/includes/changes/CategoryMembershipChange.php b/includes/changes/CategoryMembershipChange.php index 2728fdd2021..6d0405741ae 100644 --- a/includes/changes/CategoryMembershipChange.php +++ b/includes/changes/CategoryMembershipChange.php @@ -70,8 +70,9 @@ class CategoryMembershipChange { public function __construct( Title $pageTitle, $revision = null ) { $this->pageTitle = $pageTitle; if ( $revision instanceof Revision ) { - wfDeprecated( - 'Revision for ' . __METHOD__, + wfDeprecatedMsg( + 'Passing a Revision for the $revision parameter to ' . __METHOD__ . + ' was deprecated in MediaWiki 1.35', '1.35' ); $revision = $revision->getRevisionRecord(); diff --git a/includes/db/MWLBFactory.php b/includes/db/MWLBFactory.php index 83200914e57..1434f2b2bd7 100644 --- a/includes/db/MWLBFactory.php +++ b/includes/db/MWLBFactory.php @@ -313,11 +313,12 @@ abstract class MWLBFactory { $class = $config['class']; if ( isset( $bcClasses[$class] ) ) { - $class = $bcClasses[$class]; - wfDeprecated( - '$wgLBFactoryConf must be updated. See RELEASE-NOTES for details', + wfDeprecatedMsg( + '$wgLBFactoryConf must be updated. ' . + "The class $class was renamed to {$bcClasses[$class]} in MediaWiki 1.23.", '1.23' ); + $class = $bcClasses[$class]; } // For configuration backward compatibility after moving classes to namespaces (1.29) diff --git a/includes/debug/MWDebug.php b/includes/debug/MWDebug.php index da75ac17b51..d0cd12e083e 100644 --- a/includes/debug/MWDebug.php +++ b/includes/debug/MWDebug.php @@ -225,15 +225,53 @@ class MWDebug { public static function deprecated( $function, $version = false, $component = false, $callerOffset = 2 ) { - $callerDescription = self::getCallerDescription( $callerOffset ); - $callerFunc = $callerDescription['func']; + if ( $version ) { + $component = $component ?: 'MediaWiki'; + $msg = "Use of $function was deprecated in $component $version."; + } else { + $msg = "Use of $function is deprecated."; + } + self::deprecatedMsg( $msg, $version, $component, $callerOffset + 1 ); + } + + /** + * Log a deprecation warning with arbitrary message text. A caller + * description will be appended. If the message has already been sent for + * this caller, it won't be sent again. + * + * Although there are component and version parameters, they are not + * automatically appended to the message. The message text should include + * information about when the thing was deprecated. + * + * @since 1.35 + * + * @param string $msg The message + * @param string|false $version Version of MediaWiki that the function + * was deprecated in. + * @param string|bool $component Component to which the function belongs. + * If false, it is assumed the function is in MediaWiki core. + * @param int|false $callerOffset How far up the call stack is the original + * caller. 2 = function that called the function that called us. If false, + * the caller description will not be appended. + */ + public static function deprecatedMsg( $msg, $version = false, + $component = false, $callerOffset = 2 + ) { + if ( $callerOffset === false ) { + $callerFunc = ''; + $rawMsg = $msg; + } else { + $callerDescription = self::getCallerDescription( $callerOffset ); + $callerFunc = $callerDescription['func']; + $rawMsg = self::formatCallerDescription( $msg, $callerDescription ); + } $sendToLog = true; // Check to see if there already was a warning about this function - if ( isset( self::$deprecationWarnings[$function][$callerFunc] ) ) { + if ( isset( self::$deprecationWarnings[$msg][$callerFunc] ) ) { return; - } elseif ( isset( self::$deprecationWarnings[$function] ) ) { + } elseif ( isset( self::$deprecationWarnings[$msg] ) ) { if ( self::$enabled ) { $sendToLog = false; } else { @@ -241,7 +279,7 @@ class MWDebug { } } - self::$deprecationWarnings[$function][$callerFunc] = true; + self::$deprecationWarnings[$msg][$callerFunc] = true; if ( $version ) { global $wgDeprecationReleaseLimit; @@ -257,22 +295,18 @@ class MWDebug { $sendToLog = false; } } - - $component = $component ?: 'MediaWiki'; - $msg = "Use of $function was deprecated in $component $version."; - } else { - $msg = "Use of $function is deprecated."; } self::sendRawDeprecated( - self::formatCallerDescription( $msg, $callerDescription ), + $rawMsg, $sendToLog, $callerFunc ); } /** * Send a raw deprecation message to the log and the debug toolbar, - * without filtering of duplicate messages. + * without filtering of duplicate messages. A caller description will + * not be appended. * * @param string $msg The complete message including relevant caller information. * @param bool $sendToLog If true, the message will be sent to the debug diff --git a/includes/filerepo/file/LocalFileDeleteBatch.php b/includes/filerepo/file/LocalFileDeleteBatch.php index a4e7510915d..fd9ccd9ff05 100644 --- a/includes/filerepo/file/LocalFileDeleteBatch.php +++ b/includes/filerepo/file/LocalFileDeleteBatch.php @@ -79,10 +79,10 @@ class LocalFileDeleteBatch { $suppress = $param4; } else { // Old signature - wfDeprecated( - __CLASS__ . - ' being constructed without passing a user as the second parameter.' . - ' See T245710 for more', + wfDeprecatedMsg( + 'Construction of ' . __CLASS__ . ' without passing a user as ' . + 'the second parameter was deprecated in MediaWiki 1.35. ' . + 'See T245710 for more', '1.35' ); diff --git a/includes/htmlform/fields/HTMLInfoField.php b/includes/htmlform/fields/HTMLInfoField.php index ab59ff0343a..ea1b58f109a 100644 --- a/includes/htmlform/fields/HTMLInfoField.php +++ b/includes/htmlform/fields/HTMLInfoField.php @@ -83,8 +83,9 @@ class HTMLInfoField extends HTMLFormField { public function getOOUI( $value ) { if ( !empty( $this->mParams['rawrow'] ) ) { if ( !( $value instanceof OOUI\FieldLayout ) ) { - wfDeprecated( __METHOD__ . ": 'default' parameter as a string when using" . - "'rawrow' (must be a FieldLayout or subclass)", '1.32' ); + wfDeprecatedMsg( __METHOD__ . ": 'default' parameter as a string when using " . + "'rawrow' was deprecated in MediaWiki 1.32 (must be a FieldLayout or subclass)", + '1.32' ); } return $value; } diff --git a/includes/libs/virtualrest/ParsoidVirtualRESTService.php b/includes/libs/virtualrest/ParsoidVirtualRESTService.php index 16c1297eb2b..14f620f972b 100644 --- a/includes/libs/virtualrest/ParsoidVirtualRESTService.php +++ b/includes/libs/virtualrest/ParsoidVirtualRESTService.php @@ -47,8 +47,9 @@ class ParsoidVirtualRESTService extends VirtualRESTService { public function __construct( array $params ) { // for backwards compatibility: if ( isset( $params['URL'] ) ) { - wfDeprecated( - 'Using all-caps URL parameter to $wgVirtualRestConfig', '1.35' + wfDeprecatedMsg( + 'Using all-caps URL parameter to $wgVirtualRestConfig ' . + 'was deprecated in MediaWiki 1.35', '1.35' ); $params['url'] = $params['URL']; unset( $params['URL'] ); diff --git a/includes/page/Article.php b/includes/page/Article.php index 78a3dfedad6..4beaa2c7e74 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -2329,7 +2329,8 @@ class Article implements Page { * @return mixed */ public function __get( $fname ) { - wfDeprecated( __METHOD__ . " Access to raw $fname field", '1.35' ); + wfDeprecatedMsg( "Accessing Article::\$$fname is deprecated since MediaWiki 1.35", + '1.35' ); if ( $fname === 'mRevision' ) { $record = $this->fetchRevisionRecord(); // Ensure that it is loaded @@ -2352,7 +2353,8 @@ class Article implements Page { * @param mixed $fvalue New value */ public function __set( $fname, $fvalue ) { - wfDeprecated( __METHOD__ . " Access to raw $fname field", '1.35' ); + wfDeprecatedMsg( "Setting Article::\$$fname is deprecated since MediaWiki 1.35", + '1.35' ); if ( $fname === 'mRevision' ) { $this->mRevisionRecord = $fvalue ? diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 6ffd55ce8a9..365e6494944 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -2780,14 +2780,17 @@ class Parser { $this->hookRunner->onParserGetVariableValueSwitch( $this, $this->mVarCache, $index, $ret, $frame ); if ( $index !== $originalIndex ) { - wfDeprecated( - 'ParserGetVariableValueSwitch modifying $index', '1.35' + wfDeprecatedMsg( + 'A ParserGetVariableValueSwitch hook handler modified $index, ' . + 'this is deprecated since MediaWiki 1.35', + '1.35', false, false ); } if ( !isset( $this->mVarCache[$originalIndex] ) || $this->mVarCache[$originalIndex] !== $ret ) { - wfDeprecated( - 'ParserGetVariableValueSwitch bypassing cache', '1.35' + wfDeprecatedMsg( + 'A ParserGetVariableValueSwitch hook handler bypassed the cache, ' . + 'this is deprecated since MediaWiki 1.35', '1.35', false, false ); }// FIXME: in the future, don't give this hook unrestricted // access to mVarCache; we can cache it ourselves by falling diff --git a/includes/parser/ParserOptions.php b/includes/parser/ParserOptions.php index 97cbc5142cb..43a0bca5c7d 100644 --- a/includes/parser/ParserOptions.php +++ b/includes/parser/ParserOptions.php @@ -311,7 +311,7 @@ class ParserOptions { */ public function setTidy( $x ) { if ( !$x ) { - wfDeprecated( 'disabling tidy', '1.33' ); + wfDeprecatedMsg( 'Disabling tidy is deprecated since MediaWiki 1.33', '1.33' ); } return $this->setOptionLegacy( 'tidy', $x ); } diff --git a/includes/parser/Sanitizer.php b/includes/parser/Sanitizer.php index 18663e37837..f923a205d60 100644 --- a/includes/parser/Sanitizer.php +++ b/includes/parser/Sanitizer.php @@ -445,7 +445,8 @@ class Sanitizer { ]; if ( $wgAllowImageTag ) { - wfDeprecated( 'Setting $wgAllowImageTag to true', '1.35' ); + wfDeprecatedMsg( 'Setting $wgAllowImageTag to true ' . + 'is deprecated since MediaWiki 1.35', '1.35', false, false ); $htmlsingle[] = 'img'; $htmlsingleonly[] = 'img'; } diff --git a/includes/registration/ExtensionRegistry.php b/includes/registration/ExtensionRegistry.php index 957a88cdfe8..578a596f5c9 100644 --- a/includes/registration/ExtensionRegistry.php +++ b/includes/registration/ExtensionRegistry.php @@ -348,9 +348,10 @@ class ExtensionRegistry { } if ( !isset( $info['manifest_version'] ) ) { - wfDeprecated( - "{$info['name']}'s extension.json or skin.json does not have manifest_version", - '1.29' + wfDeprecatedMsg( + "{$info['name']}'s extension.json or skin.json does not have manifest_version, " . + 'this is deprecated since MediaWiki 1.29', + '1.29', false, false ); $warnings = true; // For backwards-compatibility, assume a version of 1 diff --git a/includes/search/searchwidgets/DidYouMeanWidget.php b/includes/search/searchwidgets/DidYouMeanWidget.php index cca2b699cef..c4c61d0e9ca 100644 --- a/includes/search/searchwidgets/DidYouMeanWidget.php +++ b/includes/search/searchwidgets/DidYouMeanWidget.php @@ -60,9 +60,10 @@ class DidYouMeanWidget { // was only documented but not enforced previously emit a // deprecation warning and in the future we can simply fail on bad // inputs - wfDeprecated( - get_class( $resultSet ) . '::getQueryAfterRewriteSnippet returning empty snippet', - '1.34' + wfDeprecatedMsg( + get_class( $resultSet ) . '::getQueryAfterRewriteSnippet returning empty snippet ' . + 'was deprecated in MediaWiki 1.35', + '1.34', false, false ); $snippet = $resultSet->getQueryAfterRewrite(); } @@ -109,9 +110,10 @@ class DidYouMeanWidget { // was only documented but not enforced previously emit a // deprecation warning and in the future we can simply fail on bad // inputs - wfDeprecated( - get_class( $resultSet ) . '::getSuggestionSnippet returning empty snippet', - '1.34' + wfDeprecatedMsg( + get_class( $resultSet ) . '::getSuggestionSnippet returning empty snippet ' . + 'was deprecated in MediaWiki 1.35', + '1.34', false, false ); $snippet = $resultSet->getSuggestionSnippet(); } diff --git a/includes/specialpage/SpecialPageFactory.php b/includes/specialpage/SpecialPageFactory.php index 7d7e95b3474..59ecef8bfa0 100644 --- a/includes/specialpage/SpecialPageFactory.php +++ b/includes/specialpage/SpecialPageFactory.php @@ -455,9 +455,10 @@ class SpecialPageFactory { $rec = $specialPageList[$realName]; if ( $rec instanceof SpecialPage ) { - wfDeprecated( - "a SpecialPage instance (for $realName) in " . - '$wgSpecialPages or from the SpecialPage_initList hook', + wfDeprecatedMsg( + "A SpecialPage instance for $realName was found in " . + '$wgSpecialPages or came from a SpecialPage_initList hook handler, ' . + 'this was deprecated in MediaWiki 1.34', '1.34' ); diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index 1a6d04f30d7..e84a12c63e9 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -656,9 +656,9 @@ class SpecialContributions extends IncludableSpecialPage { 'section' => 'contribs-top', ]; wfDeprecated( - __METHOD__ . - ' returning string[]', - '1.33' + 'A SpecialContributions::getForm::filters hook handler returned ' . + 'an array of strings, this is deprecated since MediaWiki 1.33', + '1.33', false, false ); } else { // Preferred append method. diff --git a/includes/specials/SpecialEmailUser.php b/includes/specials/SpecialEmailUser.php index d09ed9c7875..a9db7075d0d 100644 --- a/includes/specials/SpecialEmailUser.php +++ b/includes/specials/SpecialEmailUser.php @@ -414,7 +414,9 @@ class SpecialEmailUser extends UnlistedSpecialPage { // Ugh. Either a raw HTML string, or something that's supposed // to be treated like one. $type = is_object( $error ) ? get_class( $error ) : gettype( $error ); - wfDeprecated( "EmailUser hook returning a $type as \$error", '1.29' ); + wfDeprecatedMsg( "An EmailUser hook returned a $type as \$error, " . + "this is deprecated since MediaWiki 1.29", + '1.29', false, false ); return Status::newFatal( new ApiRawMessage( [ '$1', Message::rawParam( (string)$error ) ], 'hookaborted' ) ); diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index 90abebb69c6..20506cbaa90 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -378,8 +378,9 @@ class SpecialSearch extends SpecialPage { $rewritten = $engine->replacePrefixes( $term ); if ( $rewritten !== $term ) { - wfDeprecated( 'SearchEngine::replacePrefixes() (overridden by ' . - get_class( $engine ) . ')', '1.32' ); + wfDeprecatedMsg( 'SearchEngine::replacePrefixes() was overridden by ' . + get_class( $engine ) . ', this is deprecated since MediaWiki 1.32', + '1.32', false, false ); } // fetch search results diff --git a/includes/title/NamespaceInfo.php b/includes/title/NamespaceInfo.php index 37d93784a10..1d45c17c440 100644 --- a/includes/title/NamespaceInfo.php +++ b/includes/title/NamespaceInfo.php @@ -161,7 +161,8 @@ class NamespaceInfo { */ public function isMovable( $index ) { if ( !$this->options->get( 'AllowImageMoving' ) ) { - wfDeprecated( 'Setting $wgAllowImageMoving to false', '1.35' ); + wfDeprecatedMsg( 'Setting $wgAllowImageMoving to false was deprecated in MediaWiki 1.35', + '1.35', false, false ); } $result = $index >= NS_MAIN && diff --git a/includes/user/PasswordReset.php b/includes/user/PasswordReset.php index c66f14e7377..59d66795ca1 100644 --- a/includes/user/PasswordReset.php +++ b/includes/user/PasswordReset.php @@ -97,13 +97,15 @@ class PasswordReset implements LoggerAwareInterface { $this->permissionManager = $permissionManager; if ( !$loadBalancer ) { - wfDeprecated( 'Not passing LoadBalancer to ' . __METHOD__, '1.34' ); + wfDeprecatedMsg( 'Not passing LoadBalancer to ' . __METHOD__ . + ' was deprecated in MediaWiki 1.34', '1.34' ); $loadBalancer = MediaWikiServices::getInstance()->getDBLoadBalancer(); } $this->loadBalancer = $loadBalancer; if ( !$logger ) { - wfDeprecated( 'Not passing LoggerInterface to ' . __METHOD__, '1.34' ); + wfDeprecatedMsg( 'Not passing LoggerInterface to ' . __METHOD__ . + ' was deprecated in MediaWiki 1.34', '1.34' ); $logger = LoggerFactory::getInstance( 'authentication' ); } $this->logger = $logger; diff --git a/includes/user/User.php b/includes/user/User.php index 53480b0d7bf..63b40532d9c 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -1716,9 +1716,10 @@ class User implements IDBAccessObject, UserIdentity { } if ( $deprecatedIPEntries ) { - wfDeprecated( - 'IP addresses in the keys of $wgProxyList (found the following IP addresses in keys: ' . - implode( ', ', $deprecatedIPEntries ) . ', please move them to values)', '1.30' ); + wfDeprecatedMsg( + 'Use of IP addresses in the keys of $wgProxyList is deprecated since MediaWiki 1.30. ' . + 'Found the following IP addresses in keys: ' . implode( ', ', $deprecatedIPEntries ) . + ', please move them to values.', '1.30', false, false ); } $proxyListIPSet = new IPSet( $resultProxyList ); diff --git a/languages/Language.php b/languages/Language.php index 58b42458a74..81f76cc0b15 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -70,7 +70,9 @@ class Language { */ public function __get( string $name ) { if ( $name == "mConverter" ) { - wfDeprecated( 'Language::mConverter', '1.35' ); + wfDeprecatedMsg( + 'Access to Language::$mConverter was deprecated in MediaWiki 1.35', + '1.35' ); return $this->getConverter(); } throw new RuntimeException( "Cannot get '$name' property." ); @@ -3036,14 +3038,14 @@ class Language { protected function transformUsingPairFile( $file, $string, $basePath = null ) { if ( isset( $this->transformData[$file] ) ) { wfDeprecated( - __METHOD__ . ' structure of $transformData is changed', + 'Modification of Language::$transformData is deprecated since MediaWiki 1.35', '1.35' ); return $this->transformData[$file]->replace( $string ); } if ( $basePath === null ) { - wfDeprecated( __METHOD__ . ' $basePath is required', '1.35' ); + wfDeprecated( __METHOD__ . ' without $basePath', '1.35' ); global $IP; $basePath = $IP; } diff --git a/tests/parser/TestFileReader.php b/tests/parser/TestFileReader.php index fdc1e031639..bbd97f3581f 100644 --- a/tests/parser/TestFileReader.php +++ b/tests/parser/TestFileReader.php @@ -84,22 +84,31 @@ class TestFileReader { $nonTidySection = $this->checkSection( [ 'html/php+untidy', 'html+untidy' ], false ); if ( $this->format < 2 ) { - wfDeprecated( "parserTest v1: $this->file", '1.35' ); + wfDeprecatedMsg( + "The parserTest v1 file format was deprecated in MediaWiki 1.35 " . + "(used in {$this->file})", '1.35', false, false ); if ( $nonTidySection === false ) { // untidy by default $nonTidySection = $output; } } else { if ( $this->checkSection( [ 'input' ], false ) ) { - wfDeprecated( 'input section in parserTest', '1.35' ); + wfDeprecatedMsg( + "The input section in parserTest files was deprecated in MediaWiki 1.35 " . + "(used in {$this->file})", + '1.35', false, false ); } if ( $this->checkSection( [ 'result' ], false ) ) { - wfDeprecated( 'result section in parserTest', '1.35' ); + wfDeprecatedMsg( + "The result section in parserTest files was deprecated in MediaWiki 1.35 " . + "(used in {$this->file})", + '1.35', false, false ); } if ( $output && $tidySection ) { - wfDeprecated( - 'untidy section should be renamed at ' . - "{$this->file}:{$this->sectionLineNum['test']}", '1.35' + wfDeprecatedMsg( + 'The untidy section of parserTest files was deprecated in MediaWiki 1.35, ' . + "it should be renamed at {$this->file}:{$this->sectionLineNum['test']}", + '1.35', false, false ); } if ( $tidySection === false ) { @@ -109,7 +118,11 @@ class TestFileReader { if ( $nonTidySection && !$tidySection ) { // Tests with a "without tidy" section but no "with tidy" section // are deprecated! - wfDeprecated( "test without tidy at {$this->file}:{$this->sectionLineNum['test']}", '1.35' ); + wfDeprecatedMsg( + 'Parser tests with a "without tidy" section but no "with tidy" ' . + ' section were deprecated in MediaWiki 1.35. Found at ' . + "{$this->file}:{$this->sectionLineNum['test']}", + '1.35', false, false ); } } @@ -169,7 +182,9 @@ class TestFileReader { } else { // We can no longer run the non-tidy test, and we don't have // a tidy alternative. - wfDeprecated( 'skipping non-tidy test', '1.35' ); + wfDeprecatedMsg( "Skipping non-tidy test {$data['test']} " . + "since it was removed in MediaWiki 1.35, and there is no tidy subtest", + '1.35', false, false ); } } elseif ( $tidySection !== false ) { // No need to override desc when there is no subtest diff --git a/tests/phpunit/includes/MergeHistoryTest.php b/tests/phpunit/includes/MergeHistoryTest.php index a23f4cfbff8..1d553fa38f0 100644 --- a/tests/phpunit/includes/MergeHistoryTest.php +++ b/tests/phpunit/includes/MergeHistoryTest.php @@ -72,7 +72,7 @@ class MergeHistoryTest extends MediaWikiTestCase { * @covers MergeHistory::isValidMerge */ public function testIsValidMergeRevisionLimit() { - $this->hideDeprecated( 'MergeHistory being constructed directly' ); + $this->filterDeprecated( '/Direct construction of MergeHistory/' ); $limit = MergeHistory::REVISION_LIMIT; @@ -143,7 +143,7 @@ class MergeHistoryTest extends MediaWikiTestCase { $timestamp = false; // Old method: No dependencies injected - $this->hideDeprecated( 'MergeHistory being constructed directly' ); + $this->filterDeprecated( '/Direct construction of MergeHistory/' ); $mergeHistory = new MergeHistory( $source, $destination, $timestamp ); $this->assertInstanceOf( MergeHistory::class, diff --git a/tests/phpunit/includes/OutputPageTest.php b/tests/phpunit/includes/OutputPageTest.php index 37328059dbe..8c0bd554da1 100644 --- a/tests/phpunit/includes/OutputPageTest.php +++ b/tests/phpunit/includes/OutputPageTest.php @@ -2183,7 +2183,7 @@ class OutputPageTest extends MediaWikiTestCase { ->will( $this->returnValue( $cookies ) ); TestingAccessWrapper::newFromObject( $op )->mVaryHeader = []; - $this->hideDeprecated( 'addVaryHeader $option is ignored' ); + $this->filterDeprecated( '/The \$option parameter to addVaryHeader is ignored/' ); foreach ( $calls as $call ) { $op->addVaryHeader( ...$call ); } diff --git a/tests/phpunit/includes/db/MWLBFactoryTest.php b/tests/phpunit/includes/db/MWLBFactoryTest.php index ee805fd2829..1cd7333eb5e 100644 --- a/tests/phpunit/includes/db/MWLBFactoryTest.php +++ b/tests/phpunit/includes/db/MWLBFactoryTest.php @@ -47,7 +47,7 @@ class MWLBFactoryTest extends MediaWikiTestCase { 'serverTemplate' => [], ]; - $this->hideDeprecated( '$wgLBFactoryConf must be updated. See RELEASE-NOTES for details' ); + $this->filterDeprecated( '/\$wgLBFactoryConf must be updated/' ); $result = MWLBFactory::getLBFactoryClass( $config ); $this->assertEquals( $expected, $result ); diff --git a/tests/phpunit/includes/page/ArticleTest.php b/tests/phpunit/includes/page/ArticleTest.php index bb025f93403..38663762985 100644 --- a/tests/phpunit/includes/page/ArticleTest.php +++ b/tests/phpunit/includes/page/ArticleTest.php @@ -29,7 +29,7 @@ class ArticleTest extends \MediaWikiTestCase { * @covers Article::__get */ public function testImplementsGetMagic() { - $this->hideDeprecated( 'Article::__get Access to raw mLatest field' ); + $this->filterDeprecated( '/Accessing Article::\$mLatest/' ); $this->assertFalse( $this->article->mLatest, "Article __get magic" ); } @@ -38,8 +38,8 @@ class ArticleTest extends \MediaWikiTestCase { * @covers Article::__set */ public function testImplementsSetMagic() { - $this->hideDeprecated( 'Article::__get Access to raw mLatest field' ); - $this->hideDeprecated( 'Article::__set Access to raw mLatest field' ); + $this->filterDeprecated( '/Accessing Article::\$mLatest/' ); + $this->filterDeprecated( '/Setting Article::\$mLatest/' ); $this->article->mLatest = 2; $this->assertEquals( 2, $this->article->mLatest, "Article __set magic" ); } @@ -49,11 +49,11 @@ class ArticleTest extends \MediaWikiTestCase { * @covers Article::__set */ public function testGetOrSetOnNewProperty() { - $this->hideDeprecated( - 'Article::__get Access to raw ext_someNewProperty field' + $this->filterDeprecated( + '/Accessing Article::\$ext_someNewProperty/' ); - $this->hideDeprecated( - 'Article::__set Access to raw ext_someNewProperty field' + $this->filterDeprecated( + '/Setting Article::\$ext_someNewProperty/' ); $this->article->ext_someNewProperty = 12; $this->assertEquals( 12, $this->article->ext_someNewProperty, diff --git a/tests/phpunit/includes/title/NamespaceInfoTest.php b/tests/phpunit/includes/title/NamespaceInfoTest.php index 8f2083822f0..454ec6f1afa 100644 --- a/tests/phpunit/includes/title/NamespaceInfoTest.php +++ b/tests/phpunit/includes/title/NamespaceInfoTest.php @@ -123,7 +123,7 @@ class NamespaceInfoTest extends MediaWikiTestCase { */ public function testIsMovable( $expected, $ns, $allowImageMoving = true ) { if ( $allowImageMoving === false ) { - $this->hideDeprecated( 'Setting $wgAllowImageMoving to false' ); + $this->filterDeprecated( '/Setting \$wgAllowImageMoving to false/' ); } $obj = $this->newObj( [ 'AllowImageMoving' => $allowImageMoving ] );