Merge "Remove IDBAccessObject from being implemented in many classes"

This commit is contained in:
jenkins-bot 2024-02-21 17:35:07 +00:00 committed by Gerrit Code Review
commit 260fc1b50f
28 changed files with 52 additions and 48 deletions

View file

@ -183,6 +183,8 @@ because of Phabricator reports.
boolean true. The false case has been removed.
* MagicWord::load() has been marked @internal and may change in the future
without further notice.
* All classes that implemented IDBAccessObject interface and all interfaces
that extended it, no longer do that. See https://w.wiki/9DAX for more info.
* BagOStuff::setNewPreparedValues() now emits deprecation warnings.
* The type of the last parameter of BeforeInitializeHook::onBeforeInitialize
and MediaWikiPerformActionHook::onMediaWikiPerformAction changed from

View file

@ -35,7 +35,7 @@ use Wikimedia\Rdbms\IReadableDatabase;
* @note This was written to act as a drop-in replacement for the corresponding
* static methods in the old Revision class (which was later removed in 1.37).
*/
interface RevisionFactory extends IDBAccessObject {
interface RevisionFactory {
/**
* Constructs a RevisionRecord given a database row and content slots.

View file

@ -35,7 +35,7 @@ use MediaWiki\Page\PageIdentity;
* @since 1.31
* @since 1.32 Renamed from MediaWiki\Storage\RevisionLookup
*/
interface RevisionLookup extends IDBAccessObject {
interface RevisionLookup {
/**
* Load a page revision from a given revision ID number.

View file

@ -86,8 +86,7 @@ use Wikimedia\Rdbms\SelectQueryBuilder;
* @note This was written to act as a drop-in replacement for the corresponding
* static methods in the old Revision class (which was later removed in 1.37).
*/
class RevisionStore
implements IDBAccessObject, RevisionFactory, RevisionLookup, LoggerAwareInterface {
class RevisionStore implements RevisionFactory, RevisionLookup, LoggerAwareInterface {
use LegacyArticleIdAccess;

View file

@ -104,7 +104,7 @@ use WikiPage;
* @since 1.32
* @ingroup Page
*/
class DerivedPageDataUpdater implements IDBAccessObject, LoggerAwareInterface, PreparedUpdate {
class DerivedPageDataUpdater implements LoggerAwareInterface, PreparedUpdate {
/**
* @var UserIdentity|null

View file

@ -48,7 +48,7 @@ use Wikimedia\Rdbms\IResultWrapper;
* @note This was written to act as a drop-in replacement for the corresponding
* static methods in the old Revision class (which was later removed in 1.37).
*/
class SqlBlobStore implements IDBAccessObject, BlobStore {
class SqlBlobStore implements BlobStore {
// Note: the name has been taken unchanged from the old Revision class.
public const TEXT_CACHE_GROUP = 'revisiontext:10';

View file

@ -70,7 +70,7 @@ use MediaWiki\User\UserIdentity;
* @stable to extend
* @ingroup FileAbstraction
*/
abstract class File implements IDBAccessObject, MediaHandlerState {
abstract class File implements MediaHandlerState {
use ProtectedHookAccessorTrait;
// Bitfield values akin to the revision deletion constants

View file

@ -14,7 +14,7 @@ use MediaWiki\Linker\LinkTarget;
* @since 1.36
* @ingroup Page
*/
interface PageLookup extends IDBAccessObject {
interface PageLookup {
/**
* Returns the PageIdentity for the given LinkTarget. The page does not have to exist.

View file

@ -76,7 +76,7 @@ use Wikimedia\Rdbms\IReadableDatabase;
*
* @ingroup Page
*/
class WikiPage implements Page, IDBAccessObject, PageRecord {
class WikiPage implements Page, PageRecord {
use NonSerializableTrait;
use ProtectedHookAccessorTrait;
use WikiAwareEntityTrait;

View file

@ -75,7 +75,7 @@ use WikiPage;
* @note Consider using a TitleValue object instead. TitleValue is more lightweight
* and does not rely on global state or the database.
*/
class Title implements LinkTarget, PageIdentity, IDBAccessObject {
class Title implements LinkTarget, PageIdentity {
use WikiAwareEntityTrait;
use LinkTargetTrait;

View file

@ -48,7 +48,7 @@ use Wikimedia\Rdbms\IReadableDatabase;
* Utility class for bot passwords
* @since 1.27
*/
class BotPassword implements IDBAccessObject {
class BotPassword {
public const APPID_MAXLENGTH = 32;

View file

@ -41,7 +41,7 @@ use Wikimedia\Rdbms\IReadableDatabase;
* @author DannyS712
* @since 1.37
*/
class BotPasswordStore implements IDBAccessObject {
class BotPasswordStore {
/**
* @internal For use by ServiceWiring

View file

@ -39,7 +39,7 @@ use Throwable;
* @since 1.27
* @stable to extend
*/
abstract class CentralIdLookup implements IDBAccessObject {
abstract class CentralIdLookup {
// Audience options for accessors
public const AUDIENCE_PUBLIC = 1;
public const AUDIENCE_RAW = 2;

View file

@ -27,7 +27,7 @@ use MediaWiki\User\UserIdentity;
* Provides access to user options
* @since 1.35
*/
abstract class UserOptionsLookup implements IDBAccessObject {
abstract class UserOptionsLookup {
/**
* Exclude user options that are set to their default value.

View file

@ -38,7 +38,7 @@ use Wikimedia\Rdbms\ILoadBalancer;
*
* @since 1.35
*/
class UserFactory implements IDBAccessObject, UserRigorOptions {
class UserFactory implements UserRigorOptions {
/**
* RIGOR_* constants are inherited from UserRigorOptions

View file

@ -49,7 +49,7 @@ use Wikimedia\Rdbms\SelectQueryBuilder;
* Manages user groups.
* @since 1.35
*/
class UserGroupManager implements IDBAccessObject {
class UserGroupManager {
/**
* @internal For use by ServiceWiring

View file

@ -30,7 +30,7 @@ use Wikimedia\Rdbms\IReadableDatabase;
* @package MediaWiki\User
* @since 1.36
*/
interface UserIdentityLookup extends IDBAccessObject {
interface UserIdentityLookup {
/**
* Find an identity of a user by $name

View file

@ -936,7 +936,7 @@ class ApiEditPageTest extends ApiTestCase {
'undoafter' => $revId1,
] );
$page->loadPageData( WikiPage::READ_LATEST );
$page->loadPageData( IDBAccessObject::READ_LATEST );
$this->assertSame( '1', $page->getContent()->getText() );
}
@ -957,7 +957,7 @@ class ApiEditPageTest extends ApiTestCase {
'undo' => $revId,
] );
$page->loadPageData( WikiPage::READ_LATEST );
$page->loadPageData( IDBAccessObject::READ_LATEST );
$this->assertSame( '3', $page->getContent()->getText() );
}
@ -977,7 +977,7 @@ class ApiEditPageTest extends ApiTestCase {
'undoafter' => $revId2,
] );
$page->loadPageData( WikiPage::READ_LATEST );
$page->loadPageData( IDBAccessObject::READ_LATEST );
$this->assertSame( '2', $page->getContent()->getText() );
}

View file

@ -311,7 +311,7 @@ class MovePageTest extends MediaWikiIntegrationTestCase {
$this->assertSame( $oldPageId, $nullRevision->getPageId() );
if ( $createRedirect ) {
$this->assertInstanceOf( RevisionRecord::class, $redirectRevision );
$this->assertSame( $old->getArticleID( Title::READ_LATEST ), $redirectRevision->getPageId() );
$this->assertSame( $old->getArticleID( IDBAccessObject::READ_LATEST ), $redirectRevision->getPageId() );
} else {
$this->assertNull( $redirectRevision );
}

View file

@ -2,6 +2,7 @@
namespace MediaWiki\Tests\Page;
use Exception;
use IDBAccessObject;
use InvalidArgumentException;
use LinkCacheTestTrait;
use MediaWiki\Config\ServiceOptions;
@ -712,7 +713,7 @@ class PageStoreTest extends MediaWikiIntegrationTestCase {
[ 'dbLoadBalancer' => $lb ]
);
$pageStore->newSelectQueryBuilder( PageStore::READ_LATEST )
$pageStore->newSelectQueryBuilder( IDBAccessObject::READ_LATEST )
->fetchPageRecord();
}

View file

@ -1390,7 +1390,7 @@ class TitleTest extends MediaWikiIntegrationTestCase {
'exists() should rely on link cache unless READ_LATEST is used'
);
$this->assertTrue(
$title->exists( Title::READ_LATEST ),
$title->exists( IDBAccessObject::READ_LATEST ),
'exists() should re-query database when READ_LATEST is used'
);
}

View file

@ -357,14 +357,14 @@ class BotPasswordTest extends MediaWikiIntegrationTestCase {
] );
$this->assertFalse( $bp->isSaved() );
$this->assertNull(
BotPassword::newFromCentralId( 42, 'TestSave', BotPassword::READ_LATEST )
BotPassword::newFromCentralId( 42, 'TestSave', IDBAccessObject::READ_LATEST )
);
$passwordHash = $password ? $passwordFactory->newFromPlaintext( $password ) : null;
$this->assertStatusNotOk( $bp->save( 'update', $passwordHash ) );
$this->assertStatusGood( $bp->save( 'insert', $passwordHash ) );
$bp2 = BotPassword::newFromCentralId( 42, 'TestSave', BotPassword::READ_LATEST );
$bp2 = BotPassword::newFromCentralId( 42, 'TestSave', IDBAccessObject::READ_LATEST );
$this->assertInstanceOf( BotPassword::class, $bp2 );
$this->assertEquals( $bp->getUserCentralId(), $bp2->getUserCentralId() );
$this->assertEquals( $bp->getAppId(), $bp2->getAppId() );
@ -387,7 +387,7 @@ class BotPasswordTest extends MediaWikiIntegrationTestCase {
$this->assertStatusGood( $bp->save( 'update' ) );
$this->assertNotEquals( $token, $bp->getToken() );
$bp2 = BotPassword::newFromCentralId( 42, 'TestSave', BotPassword::READ_LATEST );
$bp2 = BotPassword::newFromCentralId( 42, 'TestSave', IDBAccessObject::READ_LATEST );
$this->assertInstanceOf( BotPassword::class, $bp2 );
$this->assertEquals( $bp->getToken(), $bp2->getToken() );
/** @var Password $pw */
@ -409,7 +409,7 @@ class BotPasswordTest extends MediaWikiIntegrationTestCase {
$this->assertTrue( $bp->delete() );
$this->assertFalse( $bp->isSaved() );
$this->assertNull( BotPassword::newFromCentralId( 42, 'TestSave', BotPassword::READ_LATEST ) );
$this->assertNull( BotPassword::newFromCentralId( 42, 'TestSave', IDBAccessObject::READ_LATEST ) );
$this->expectException( UnexpectedValueException::class );
$bp->save( 'foobar' )->isGood();

View file

@ -20,6 +20,7 @@
namespace MediaWiki\Tests\User;
use IDBAccessObject;
use InvalidArgumentException;
use LogEntryBase;
use MediaWiki\Block\DatabaseBlock;
@ -226,7 +227,7 @@ class UserGroupManagerTest extends MediaWikiIntegrationTestCase {
$user->confirmEmail();
$this->assertArrayEquals(
[ '*', 'user', 'named', 'dummy' ],
$manager->getUserImplicitGroups( $user, UserGroupManager::READ_NORMAL, true )
$manager->getUserImplicitGroups( $user, IDBAccessObject::READ_NORMAL, true )
);
$this->assertArrayEquals(
[ '*', 'user', 'named', 'dummy' ],
@ -575,7 +576,7 @@ class UserGroupManagerTest extends MediaWikiIntegrationTestCase {
$row->ug_user = $user->getId();
$row->ug_group = 'test';
$row->ug_expiry = null;
$manager->loadGroupMembershipsFromArray( $user, [ $row ], UserGroupManager::READ_NORMAL );
$manager->loadGroupMembershipsFromArray( $user, [ $row ], IDBAccessObject::READ_NORMAL );
$memberships = $manager->getUserGroupMemberships( $user );
$this->assertCount( 1, $memberships );
$this->assertArrayHasKey( 'test', $memberships );
@ -1286,7 +1287,7 @@ class UserGroupManagerTest extends MediaWikiIntegrationTestCase {
);
$this->assertArrayEquals(
[ 'sysop', 'interface-admin', 'baz' ],
$manager->getUserPrivilegedGroups( $user, UserGroupManager::READ_NORMAL, true )
$manager->getUserPrivilegedGroups( $user, IDBAccessObject::READ_NORMAL, true )
);
$this->assertArrayEquals(
[ 'sysop', 'interface-admin', 'baz' ],
@ -1300,7 +1301,7 @@ class UserGroupManagerTest extends MediaWikiIntegrationTestCase {
$user = $this->getTestUser( [] )->getUser();
$this->assertArrayEquals(
[],
$manager->getUserPrivilegedGroups( $user, UserGroupManager::READ_NORMAL, true )
$manager->getUserPrivilegedGroups( $user, IDBAccessObject::READ_NORMAL, true )
);
}
}

View file

@ -883,7 +883,7 @@ class UserTest extends MediaWikiIntegrationTestCase {
'Invalid confirmation codes result in null users when reading from replicas'
);
$user = User::newFromConfirmationCode( 'OtherFakeCode', User::READ_LATEST );
$user = User::newFromConfirmationCode( 'OtherFakeCode', IDBAccessObject::READ_LATEST );
$this->assertNull(
$user,
'Invalid confirmation codes result in null users when reading from master'

View file

@ -3,6 +3,7 @@
namespace MediaWiki\Tests\User;
use CannotCreateActorException;
use IDBAccessObject;
use InvalidArgumentException;
use MediaWiki\DAO\WikiAwareEntity;
use MediaWiki\MainConfigNames;
@ -852,7 +853,7 @@ class ActorStoreTest extends ActorStoreTestBase {
public function testNewSelectQueryBuilderWithQueryFlags() {
$store = $this->getStore();
$queryBuilder = $store->newSelectQueryBuilder( ActorStore::READ_NORMAL );
$queryBuilder = $store->newSelectQueryBuilder( IDBAccessObject::READ_NORMAL );
$this->assertInstanceOf( UserSelectQueryBuilder::class, $queryBuilder );
}
}

View file

@ -269,7 +269,7 @@ class UserOptionsManagerTest extends UserOptionsLookupTestBase {
] )
] );
$recursionCounter = 0;
$manager->loadUserOptions( $user, UserOptionsManager::READ_LATEST );
$manager->loadUserOptions( $user, IDBAccessObject::READ_LATEST );
$this->assertSame( 1, $recursionCounter );
}
@ -320,7 +320,7 @@ class UserOptionsManagerTest extends UserOptionsLookupTestBase {
'test_option',
null,
false,
UserOptionsManager::READ_LOCKING
IDBAccessObject::READ_LOCKING
);
$manager->getOption( $user, 'test_option2' );
$manager->setOption( $user, 'test_option', 'test_value' );

View file

@ -3,7 +3,6 @@
use MediaWiki\MainConfigNames;
use MediaWiki\Permissions\UltimateAuthority;
use MediaWiki\User\User;
use MediaWiki\User\UserFactory;
use MediaWiki\User\UserIdentityValue;
use Wikimedia\IPUtils;
use Wikimedia\Rdbms\IDatabase;
@ -160,7 +159,7 @@ class UserFactoryTest extends MediaWikiIntegrationTestCase {
'Invalid confirmation codes result in null users when reading from replicas'
);
$user2 = $factory->newFromConfirmationCode( $fakeCode, UserFactory::READ_LATEST );
$user2 = $factory->newFromConfirmationCode( $fakeCode, IDBAccessObject::READ_LATEST );
$this->assertNull(
$user2,
'Invalid confirmation codes result in null users when reading from master'

View file

@ -2,6 +2,7 @@
namespace MediaWiki\Tests\User\CentralId;
use IDBAccessObject;
use InvalidArgumentException;
use LogicException;
use MediaWiki\Permissions\Authority;
@ -75,13 +76,13 @@ class CentralIdLookupTest extends MediaWikiUnitTestCase {
->with(
[ 15 => null ],
CentralIdLookup::AUDIENCE_RAW,
CentralIdLookup::READ_LATEST
IDBAccessObject::READ_LATEST
)
->willReturn( [ 15 => 'FooBar' ] );
$this->assertSame(
'FooBar',
$mock->nameFromCentralId( 15, CentralIdLookup::AUDIENCE_RAW, CentralIdLookup::READ_LATEST )
$mock->nameFromCentralId( 15, CentralIdLookup::AUDIENCE_RAW, IDBAccessObject::READ_LATEST )
);
}
@ -108,13 +109,13 @@ class CentralIdLookupTest extends MediaWikiUnitTestCase {
->with(
[ 42 => null ],
CentralIdLookup::AUDIENCE_RAW,
CentralIdLookup::READ_LATEST
IDBAccessObject::READ_LATEST
)
->willReturn( [ 42 => $name ] );
$mock->init( 'test', $userIdentityLookup, $userFactory );
$user = $mock->localUserFromCentralId(
42, CentralIdLookup::AUDIENCE_RAW, CentralIdLookup::READ_LATEST
42, CentralIdLookup::AUDIENCE_RAW, IDBAccessObject::READ_LATEST
);
if ( $succeeds ) {
$this->assertInstanceOf( UserIdentity::class, $user );
@ -130,13 +131,13 @@ class CentralIdLookupTest extends MediaWikiUnitTestCase {
->with(
[ 42 => null ],
CentralIdLookup::AUDIENCE_RAW,
CentralIdLookup::READ_LATEST
IDBAccessObject::READ_LATEST
)
->willReturn( [ 42 => $name ] );
$mock->init( 'test', $userIdentityLookup, $userFactory );
$this->assertNull(
$mock->localUserFromCentralId( 42, CentralIdLookup::AUDIENCE_RAW, CentralIdLookup::READ_LATEST )
$mock->localUserFromCentralId( 42, CentralIdLookup::AUDIENCE_RAW, IDBAccessObject::READ_LATEST )
);
}
@ -156,13 +157,13 @@ class CentralIdLookupTest extends MediaWikiUnitTestCase {
->with(
[ 'FooBar' => 0 ],
CentralIdLookup::AUDIENCE_RAW,
CentralIdLookup::READ_LATEST
IDBAccessObject::READ_LATEST
)
->willReturn( [ 'FooBar' => 23 ] );
$this->assertSame(
23,
$mock->centralIdFromName( 'FooBar', CentralIdLookup::AUDIENCE_RAW, CentralIdLookup::READ_LATEST )
$mock->centralIdFromName( 'FooBar', CentralIdLookup::AUDIENCE_RAW, IDBAccessObject::READ_LATEST )
);
}
@ -174,7 +175,7 @@ class CentralIdLookupTest extends MediaWikiUnitTestCase {
->with(
[ 'FooBar' => 0 ],
CentralIdLookup::AUDIENCE_RAW,
CentralIdLookup::READ_LATEST
IDBAccessObject::READ_LATEST
)
->willReturn( [ 'FooBar' => 23 ] );
@ -183,7 +184,7 @@ class CentralIdLookupTest extends MediaWikiUnitTestCase {
$mock->centralIdFromLocalUser(
new UserIdentityValue( 10, 'FooBar' ),
CentralIdLookup::AUDIENCE_RAW,
CentralIdLookup::READ_LATEST
IDBAccessObject::READ_LATEST
)
);
@ -197,7 +198,7 @@ class CentralIdLookupTest extends MediaWikiUnitTestCase {
$mock->centralIdFromLocalUser(
new UserIdentityValue( 10, 'FooBar' ),
CentralIdLookup::AUDIENCE_RAW,
CentralIdLookup::READ_LATEST
IDBAccessObject::READ_LATEST
)
);
}