mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 19:40:55 +01:00
541d794c13
Summary: Depends on D20111. Ref T6703. Currently, each ExternalAccount row is tied to a provider by `providerType` + `providerDomain`. This effectively prevents multiple providers of the same type, since, e.g., two LDAP providers may be on different ports on the same domain. The `domain` also isn't really a useful idea anyway because you can move which hostname an LDAP server is on, and LDAP actually uses the value `self` in all cases. Yeah, yikes. Instead, just bind each account to a particular provider. Then we can have an LDAP "alice" on seven different servers on different ports on the same machine and they can all move around and we'll still have a consistent, cohesive view of the world. (On its own, this creates some issues with the link/unlink/refresh flows. Those will be updated in followups, and doing this change in a way with no intermediate breaks would require fixing them to use IDs to reference providerType/providerDomain, then fixing this, then undoing the first fix most of the way.) Test Plan: Ran migrations, sanity-checked database. See followup changes for more comprehensive testing. Reviewers: amckinley Reviewed By: amckinley Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T6703 Differential Revision: https://secure.phabricator.com/D20112
36 lines
839 B
PHP
36 lines
839 B
PHP
<?php
|
|
|
|
$account_table = new PhabricatorExternalAccount();
|
|
$account_conn = $account_table->establishConnection('w');
|
|
$table_name = $account_table->getTableName();
|
|
|
|
$config_table = new PhabricatorAuthProviderConfig();
|
|
$config_conn = $config_table->establishConnection('w');
|
|
|
|
foreach (new LiskRawMigrationIterator($account_conn, $table_name) as $row) {
|
|
if (strlen($row['providerConfigPHID'])) {
|
|
continue;
|
|
}
|
|
|
|
$config_row = queryfx_one(
|
|
$config_conn,
|
|
'SELECT phid
|
|
FROM %R
|
|
WHERE providerType = %s AND providerDomain = %s
|
|
LIMIT 1',
|
|
$config_table,
|
|
$row['accountType'],
|
|
$row['accountDomain']);
|
|
if (!$config_row) {
|
|
continue;
|
|
}
|
|
|
|
queryfx(
|
|
$account_conn,
|
|
'UPDATE %R
|
|
SET providerConfigPHID = %s
|
|
WHERE id = %d',
|
|
$account_table,
|
|
$config_row['phid'],
|
|
$row['id']);
|
|
}
|