mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
df0f5c6cee
Summary: Ref T13444. Currently, identities for a particular email address are queried with "LIKE" against a binary column, which makes the query case-sensitive. - Extract the email address into a separate "sort255" column. - Add a key for it. - Make the query a standard "IN (%Ls)" query. - Deal with weird cases where an email address is 10000 bytes long or full of binary junk. Test Plan: - Ran migration, inspected database for general sanity. - Ran query script in T13444, saw it return the same hits for "git@" and "GIT@". Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13444 Differential Revision: https://secure.phabricator.com/D20907
26 lines
639 B
PHP
26 lines
639 B
PHP
<?php
|
|
|
|
$table = new PhabricatorRepositoryIdentity();
|
|
$conn = $table->establishConnection('w');
|
|
|
|
$iterator = new LiskRawMigrationIterator($conn, $table->getTableName());
|
|
foreach ($iterator as $row) {
|
|
$name = $row['identityNameRaw'];
|
|
$name = phutil_utf8ize($name);
|
|
|
|
$email = new PhutilEmailAddress($name);
|
|
$address = $email->getAddress();
|
|
|
|
try {
|
|
queryfx(
|
|
$conn,
|
|
'UPDATE %R SET emailAddress = %ns WHERE id = %d',
|
|
$table,
|
|
$address,
|
|
$row['id']);
|
|
} catch (Exception $ex) {
|
|
// We may occasionally run into issues with binary or very long addresses.
|
|
// Just skip over them.
|
|
continue;
|
|
}
|
|
}
|