mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/OATHAuth
synced 2024-11-27 09:40:28 +00:00
Migrate callers of Database::insert() to InsertQueryBuilder
Bug: T351905 Change-Id: I298f3807b68d042b2fa92bca789dd6a2b271d4c8
This commit is contained in:
parent
f2c34614de
commit
033f9192ee
|
@ -103,11 +103,11 @@ class UpdateForMultipleDevicesSupport extends LoggedUpdateMaintenance {
|
|||
}
|
||||
|
||||
if ( $toAdd ) {
|
||||
$dbw->insert(
|
||||
'oathauth_devices',
|
||||
$toAdd,
|
||||
__METHOD__
|
||||
);
|
||||
$dbw->newInsertQueryBuilder()
|
||||
->insertInto( 'oathauth_devices' )
|
||||
->rows( $toAdd )
|
||||
->caller( __METHOD__ )
|
||||
->execute();
|
||||
}
|
||||
|
||||
$this->waitForReplication();
|
||||
|
|
|
@ -99,14 +99,17 @@ class OATHAuthModuleRegistry {
|
|||
);
|
||||
|
||||
if ( $missing ) {
|
||||
$rows = [];
|
||||
$insert = $this->dbProvider
|
||||
->getPrimaryDatabase( 'virtual-oathauth' )
|
||||
->newInsertQueryBuilder()
|
||||
->insertInto( 'oathauth_types' )
|
||||
->caller( __METHOD__ );
|
||||
|
||||
foreach ( $missing as $name ) {
|
||||
$rows[] = [ 'oat_name' => $name ];
|
||||
$insert->row( [ 'oat_name' => $name ] );
|
||||
}
|
||||
|
||||
$this->dbProvider
|
||||
->getPrimaryDatabase( 'virtual-oathauth' )
|
||||
->insert( 'oathauth_types', $rows, __METHOD__ );
|
||||
$insert->execute();
|
||||
$this->moduleIds = $this->getModuleIdsFromDatabase( true );
|
||||
}
|
||||
|
||||
|
|
|
@ -130,14 +130,6 @@ class OATHUserRepository implements LoggerAwareInterface {
|
|||
$userId = $this->centralIdLookupFactory->getLookup()->centralIdFromLocalUser( $user->getUser() );
|
||||
|
||||
$moduleId = $this->moduleRegistry->getModuleId( $user->getModule()->getName() );
|
||||
$rows = [];
|
||||
foreach ( $user->getKeys() as $key ) {
|
||||
$rows[] = [
|
||||
'oad_user' => $userId,
|
||||
'oad_type' => $moduleId,
|
||||
'oad_data' => FormatJson::encode( $key->jsonSerialize() )
|
||||
];
|
||||
}
|
||||
|
||||
$dbw = $this->dbProvider->getPrimaryDatabase( 'virtual-oathauth' );
|
||||
$dbw->startAtomic( __METHOD__ );
|
||||
|
@ -148,11 +140,19 @@ class OATHUserRepository implements LoggerAwareInterface {
|
|||
[ 'oad_user' => $userId ],
|
||||
__METHOD__
|
||||
);
|
||||
$dbw->insert(
|
||||
'oathauth_devices',
|
||||
$rows,
|
||||
__METHOD__
|
||||
);
|
||||
|
||||
$insert = $dbw->newInsertQueryBuilder()
|
||||
->insertInto( 'oathauth_devices' )
|
||||
->caller( __METHOD__ );
|
||||
foreach ( $user->getKeys() as $key ) {
|
||||
$insert->row( [
|
||||
'oad_user' => $userId,
|
||||
'oad_type' => $moduleId,
|
||||
'oad_data' => FormatJson::encode( $key->jsonSerialize() )
|
||||
] );
|
||||
}
|
||||
$insert->execute();
|
||||
|
||||
$dbw->endAtomic( __METHOD__ );
|
||||
|
||||
$userName = $user->getUser()->getName();
|
||||
|
|
|
@ -33,11 +33,11 @@ class OATHAuthModuleRegistryTest extends MediaWikiIntegrationTestCase {
|
|||
* @covers \MediaWiki\Extension\OATHAuth\OATHAuthModuleRegistry::getModuleIds
|
||||
*/
|
||||
public function testGetModuleIds() {
|
||||
$this->db->insert(
|
||||
'oathauth_types',
|
||||
[ 'oat_name' => 'first' ],
|
||||
__METHOD__
|
||||
);
|
||||
$this->db->newInsertQueryBuilder()
|
||||
->insertInto( 'oathauth_types' )
|
||||
->row( [ 'oat_name' => 'first' ] )
|
||||
->caller( __METHOD__ )
|
||||
->execute();
|
||||
|
||||
$database = $this->createMock( IConnectionProvider::class );
|
||||
$database->method( 'getPrimaryDatabase' )->with( 'virtual-oathauth' )->willReturn( $this->db );
|
||||
|
|
Loading…
Reference in a new issue