mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/OATHAuth
synced 2024-12-18 02:50:33 +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 = $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(
|
$dbw->delete(
|
||||||
'oathauth_devices',
|
'oathauth_devices',
|
||||||
[ 'oad_user' => $userId ],
|
[ 'oad_user' => $userId ],
|
||||||
|
@ -200,8 +210,8 @@ class OATHUserRepository implements LoggerAwareInterface {
|
||||||
$rows,
|
$rows,
|
||||||
__METHOD__
|
__METHOD__
|
||||||
);
|
);
|
||||||
}
|
$dbw->endAtomic( __METHOD__ );
|
||||||
if ( $this->getMultipleDevicesMigrationStage() & SCHEMA_COMPAT_WRITE_OLD ) {
|
} elseif ( $this->getMultipleDevicesMigrationStage() & SCHEMA_COMPAT_WRITE_OLD ) {
|
||||||
$data = [
|
$data = [
|
||||||
'keys' => []
|
'keys' => []
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue