Formally deprecate code marked with @deprecated

Some of these have been marked in-code as deprecated for a long while,
but haven't ever been announced in the RELEASE-NOTES (and later,
HISTORY) file, so let's mark them up now so we can get the ball rolling
at least.

Per Gergo, the AuthManager one was 'born deprecated' and should only
have been used by humans also reading the deprecation notice given in
the code, and indeed no uses are known to code search, so also emit
deprecation warnings there immediately; others will have to wait until
uses have been migrated.

Change-Id: I0c1c71d8f4293623039302da35d58d2a24367e97
This commit is contained in:
James D. Forrester 2024-04-30 18:24:34 +01:00
parent 8a22b67489
commit 3ed6668745
10 changed files with 35 additions and 10 deletions

View file

@ -1,4 +1,4 @@
= MediaWiki 1.43 =
=<<< MediaWiki 1.43 =
== MediaWiki 1.43.0-PRERELEASE ==
@ -169,6 +169,19 @@ because of Phabricator reports.
warnings. Use ::getConnection() instead.
* IDatabase::lockForUpdate is deprecated, use
SelectQueryBuilder::acquireRowLocks instead.
* wfGetUrlUtils() is deprecated; instead, get a UrlUtils from services.
* DerivedPageDataUpdater::getPreparedEdit(), provided for back-compatibility, is
now deprecated; use the getters directly, instead.
* AuthManager::forcePrimaryAuthenticationProviders(), provided for back-
compatibility, is now deprecated.
* WikiPage::hasDifferencesOutsideMainSlot(), provided as a stop-gap before
refactoring to support MCR, is now deprecated.
* ChangesList::getTimestamp() has been deprecated; use ::revDateLink() instead.
* SiteConfig::variants() has been deprecated; use ::variantsFor().
* ObjectCache::$instances and ::getInstance() have been deprecated; instead, use
ObjectCacheFactory::getInstance().
* ApiTestCase::setExpectedApiException() has been deprecated; instead, use
::expectApiErrorCode() to test error codes instead of messages.
* User::isBlockedGlobally(), deprecated since 1.40, now emits deprecation
warnings.
* User::isBlockedFromEmailuser() and User::canSendEmail(), deprecated since

View file

@ -457,7 +457,7 @@ function wfAppendQuery( $url, $query ) {
}
/**
* @deprecated Get a UrlUtils from services, or construct your own
* @deprecated since 1.43; get a UrlUtils from services, or construct your own
* @internal
* @return UrlUtils from services if initialized, otherwise make one from globals
*/

View file

@ -1402,7 +1402,7 @@ class DerivedPageDataUpdater implements LoggerAwareInterface, PreparedUpdate {
}
/**
* @deprecated This only exists for B/C, use the getters on DerivedPageDataUpdater directly!
* @deprecated since 1.43; This only exists for B/C, use the getters on DerivedPageDataUpdater directly!
* @return PreparedEdit
*/
public function getPreparedEdit() {

View file

@ -309,11 +309,14 @@ class AuthManager implements LoggerAwareInterface {
/**
* Force certain PrimaryAuthenticationProviders
* @deprecated For backwards compatibility only
*
* @deprecated since 1.43; for backwards compatibility only
* @param PrimaryAuthenticationProvider[] $providers
* @param string $why
*/
public function forcePrimaryAuthenticationProviders( array $providers, $why ) {
wfDeprecated( __METHOD__, '1.43' );
$this->logger->warning( "Overriding AuthManager primary authn because $why" );
if ( $this->primaryAuthenticationProviders !== null ) {

View file

@ -671,7 +671,7 @@ class ChangesList extends ContextSource {
* and a separator
*
* @param RecentChange $rc
* @deprecated use revDateLink instead.
* @deprecated since 1.43; use revDateLink instead.
* @return string HTML fragment
*/
public function getTimestamp( $rc ) {

View file

@ -29,7 +29,7 @@ use MediaWiki\MediaWikiServices;
*/
class ObjectCache {
/**
* @deprecated Use ObjectCacheFactory instead.
* @deprecated since 1.43; use ObjectCacheFactory instead.
* @var BagOStuff[] Map of (id => BagOStuff)
*/
public static $instances = [];
@ -43,7 +43,7 @@ class ObjectCache {
/**
* Get a cached instance of the specified type of cache object.
*
* @deprecated Use ObjectCacheFactory::getInstance instead.
* @deprecated since 1.43; use ObjectCacheFactory::getInstance instead.
*
* @param string|int $id A key in $wgObjectCaches.
* @return BagOStuff

View file

@ -1486,7 +1486,7 @@ class WikiPage implements Page, PageRecord {
*
* MCR migration note: this method should go away!
*
* @deprecated Use only as a stop-gap before refactoring to support MCR.
* @deprecated since 1.43; Use only as a stop-gap before refactoring to support MCR.
*
* @param RevisionRecord $a
* @param RevisionRecord $b

View file

@ -569,9 +569,14 @@ class SiteConfig extends ISiteConfig {
* values are arrays with two fields:
* - base: (string) Base language code (e.g. "zh") (MediaWiki-internal)
* - fallbacks: (string[]) Fallback variants (MediaWiki-internal codes)
* @deprecated Use ::variantsFor() (T320662)
* @deprecated since 1.43; use ::variantsFor() (T320662)
*/
public function variants(): array {
// Deprecated for all external callers; to make private and remove this warning.
if ( wfGetCaller() !== __CLASS__ . '->variantsFor' ) {
wfDeprecated( __METHOD__, '1.43' );
}
if ( $this->variants !== null ) {
return $this->variants;
}

View file

@ -246,7 +246,8 @@ abstract class ApiTestCase extends MediaWikiLangTestCase {
* ApiUsageException::newWithMessage()'s parameters. This allows checking for an exception
* whose text is given by a message key instead of text, so as not to hard-code the message's
* text into test code.
* @deprecated Use expectApiErrorCode() instead, it's better to test error codes than messages
*
* @deprecated since 1.43; use expectApiErrorCode() instead, it's better to test error codes than messages
* @param string|array|Message $msg
* @param string|null $code
* @param array|null $data

View file

@ -825,6 +825,7 @@ class AuthManagerTest extends MediaWikiIntegrationTestCase {
// Test without first initializing the configured providers
$this->initializeManager();
$this->expectDeprecationAndContinue( '/AuthManager::forcePrimaryAuthenticationProviders/' );
$this->manager->forcePrimaryAuthenticationProviders( [ $mockB ], 'testing' );
$this->assertSame(
[ 'B' => $mockB ], $this->managerPriv->getPrimaryAuthenticationProviders()
@ -842,6 +843,7 @@ class AuthManagerTest extends MediaWikiIntegrationTestCase {
$this->assertSame( null, $this->managerPriv->getAuthenticationProvider( 'B' ) );
$this->request->getSession()->setSecret( AuthManager::AUTHN_STATE, 'test' );
$this->request->getSession()->setSecret( AuthManager::ACCOUNT_CREATION_STATE, 'test' );
$this->expectDeprecationAndContinue( '/AuthManager::forcePrimaryAuthenticationProviders/' );
$this->manager->forcePrimaryAuthenticationProviders( [ $mockB ], 'testing' );
$this->assertSame(
[ 'B' => $mockB ], $this->managerPriv->getPrimaryAuthenticationProviders()
@ -864,6 +866,7 @@ class AuthManagerTest extends MediaWikiIntegrationTestCase {
// Test duplicate IDs
$this->initializeManager();
try {
$this->expectDeprecationAndContinue( '/AuthManager::forcePrimaryAuthenticationProviders/' );
$this->manager->forcePrimaryAuthenticationProviders( [ $mockB, $mockB2 ], 'testing' );
$this->fail( 'Expected exception not thrown' );
} catch ( RuntimeException $ex ) {