mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-21 13:00:56 +01:00
237ca095a6
Summary: Fixes T3069. Ref T3516. For a long time, LDAP import added trailing whitespace to real names when importing them (for example, `"John Smith"` would be imported as `"John Smith "`). We no longer do this, but should clean up the database since it seems highly unlikely that any user wants trailing whitespace in their real name. Test Plan: $ ./bin/storage upgrade -f --apply phabricator:20130711.trimrealnames.php Applying patch 'phabricator:20130711.trimrealnames.php'... Trimming trailing whitespace from user real names... Trimming user 1 from 'Evan Priestley ' to 'Evan Priestley'. User 4 is already trim. User 5 is already trim. User 6 is already trim. User 7 is already trim. User 8 is already trim. User 9 is already trim. User 10 is already trim. User 11 is already trim. User 12 is already trim. User 13 is already trim. User 14 is already trim. User 15 is already trim. User 21 is already trim. User 22 is already trim. User 26 is already trim. User 28 is already trim. User 29 is already trim. User 32 is already trim. User 33 is already trim. User 35 is already trim. User 39 is already trim. User 51 is already trim. User 53 is already trim. User 54 is already trim. User 55 is already trim. Done. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T3069, T3516 Differential Revision: https://secure.phabricator.com/D6426
26 lines
571 B
PHP
26 lines
571 B
PHP
<?php
|
|
|
|
$table = new PhabricatorUser();
|
|
$conn_w = $table->establishConnection('w');
|
|
|
|
echo "Trimming trailing whitespace from user real names...\n";
|
|
foreach (new LiskMigrationIterator($table) as $user) {
|
|
$id = $user->getID();
|
|
$real = $user->getRealName();
|
|
$trim = rtrim($real);
|
|
|
|
if ($trim == $real) {
|
|
echo "User {$id} is already trim.\n";
|
|
continue;
|
|
}
|
|
|
|
echo "Trimming user {$id} from '{$real}' to '{$trim}'.\n";
|
|
qsprintf(
|
|
$conn_w,
|
|
'UPDATE %T SET realName = %s WHERE id = %d',
|
|
$table->getTableName(),
|
|
$real,
|
|
$id);
|
|
}
|
|
|
|
echo "Done.\n";
|