ActorNormalization::acquireActorId - require IDatabase

Bug: T276986
Change-Id: I8713a975681355cf3061d35ef5d7944c1d918d21
This commit is contained in:
Petr Pchelko 2021-05-25 07:28:19 -07:00
parent 2b5a3f7d93
commit 2600a0de39
3 changed files with 7 additions and 22 deletions

View file

@ -351,6 +351,8 @@ because of Phabricator reports.
Use SessionProvider::getConfig to get a config.
* The DBAccessBase class is deprecated. Classes that used to extend it
should get a load balancer (factory) injected in the constructor instead.
* ActorNormalization::acquireActorId now requires IDatabase parameter.
Not providing one emitted deprecation warnings since 1.36.
* …
== Compatibility ==

View file

@ -90,15 +90,12 @@ interface ActorNormalization {
* If it is already assigned, return the existing ID.
*
* @param UserIdentity $user
* @param IDatabase|null $dbw The database connection to acquire the ID from.
* @param IDatabase $dbw The database connection to acquire the ID from.
* The database must correspond to the wiki this ActorNormalization is bound to.
* If not given, a connection for this ActorNormalization's wiki will be created.
* Not providing a database connection triggers a deprecation warning!
* In the future, this parameter will be required.
* @return int greater then 0
* @throws CannotCreateActorException if no actor ID has been assigned to this $user
*/
public function acquireActorId( UserIdentity $user, IDatabase $dbw = null ): int;
public function acquireActorId( UserIdentity $user, IDatabase $dbw ): int;
/**
* Find an actor by $id.

View file

@ -399,27 +399,13 @@ class ActorStore implements UserIdentityLookup, ActorNormalization {
* transaction context.
*
* @param UserIdentity $user
* @param IDatabase|null $dbw The database connection to acquire the ID from.
* @param IDatabase $dbw The database connection to acquire the ID from.
* The database must correspond to ActorStore's wiki ID.
* If not given, an appropriate database connection will acquired from the
* LoadBalancer provided to the constructor.
* Not providing a database connection triggers a deprecation warning!
* In the future, this parameter will be required.
* @return int actor ID greater then 0
* @throws CannotCreateActorException if no actor ID has been assigned to this $user
*/
public function acquireActorId( UserIdentity $user, IDatabase $dbw = null ): int {
if ( $dbw ) {
$this->checkDatabaseDomain( $dbw );
} else {
// TODO: Remove after fixing it in all extensions and seeing it live for one train.
// Does not need full deprecation since this method is new in 1.36.
wfDeprecatedMsg(
'Calling acquireActorId() without the $dbw parameter is deprecated',
'1.36'
);
[ $dbw, ] = $this->getDBConnectionRefForQueryFlags( self::READ_LATEST );
}
public function acquireActorId( UserIdentity $user, IDatabase $dbw ): int {
$this->checkDatabaseDomain( $dbw );
[ $userId, $userName ] = $this->validateActorForInsertion( $user );
// allow cache to be used, because if it is in the cache, it already has an actor ID