From 2600a0de3905f71aaa9fc8a198b5bc40f04ed866 Mon Sep 17 00:00:00 2001 From: Petr Pchelko Date: Tue, 25 May 2021 07:28:19 -0700 Subject: [PATCH] ActorNormalization::acquireActorId - require IDatabase Bug: T276986 Change-Id: I8713a975681355cf3061d35ef5d7944c1d918d21 --- RELEASE-NOTES-1.37 | 2 ++ includes/user/ActorNormalization.php | 7 ++----- includes/user/ActorStore.php | 20 +++----------------- 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/RELEASE-NOTES-1.37 b/RELEASE-NOTES-1.37 index 3ee4a4426e0..61d43e1960c 100644 --- a/RELEASE-NOTES-1.37 +++ b/RELEASE-NOTES-1.37 @@ -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 == diff --git a/includes/user/ActorNormalization.php b/includes/user/ActorNormalization.php index e7f3be0469c..2a0ceff0907 100644 --- a/includes/user/ActorNormalization.php +++ b/includes/user/ActorNormalization.php @@ -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. diff --git a/includes/user/ActorStore.php b/includes/user/ActorStore.php index 2dface04a26..b4bd71803be 100644 --- a/includes/user/ActorStore.php +++ b/includes/user/ActorStore.php @@ -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