mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/OATHAuth
synced 2024-11-27 17:50:15 +00:00
OAuthUserRepository: Ensure we don't end up with duplicate rows
To do the migration we need to ensure that a single user has rows in either the old oathauth_users table, or the new oauthauth_devices table, but not in both. Also add a missing startAtomic/endAtomic. Bug: T242031 Change-Id: Ib0d42370b7206ff031873182c3fd957449656de8
This commit is contained in:
parent
2cb0c48655
commit
167d3670cb
|
@ -188,8 +188,18 @@ class OATHUserRepository implements LoggerAwareInterface {
|
|||
];
|
||||
}
|
||||
|
||||
// TODO: only update changed rows
|
||||
$dbw = $this->database->getDB( DB_PRIMARY );
|
||||
$dbw->startAtomic( __METHOD__ );
|
||||
|
||||
if ( $this->getMultipleDevicesMigrationStage() & SCHEMA_COMPAT_WRITE_OLD ) {
|
||||
$dbw->delete(
|
||||
'oathauth_users',
|
||||
[ 'id' => $userId ],
|
||||
__METHOD__
|
||||
);
|
||||
}
|
||||
|
||||
// TODO: only update changed rows
|
||||
$dbw->delete(
|
||||
'oathauth_devices',
|
||||
[ 'oad_user' => $userId ],
|
||||
|
@ -200,8 +210,8 @@ class OATHUserRepository implements LoggerAwareInterface {
|
|||
$rows,
|
||||
__METHOD__
|
||||
);
|
||||
}
|
||||
if ( $this->getMultipleDevicesMigrationStage() & SCHEMA_COMPAT_WRITE_OLD ) {
|
||||
$dbw->endAtomic( __METHOD__ );
|
||||
} elseif ( $this->getMultipleDevicesMigrationStage() & SCHEMA_COMPAT_WRITE_OLD ) {
|
||||
$data = [
|
||||
'keys' => []
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue