Changeset View
Changeset View
Standalone View
Standalone View
resources/sql/patches/20130711.trimrealnames.php
| <?php | <?php | ||||
| $table = new PhabricatorUser(); | $table = new PhabricatorUser(); | ||||
| $conn_w = $table->establishConnection('w'); | $conn_w = $table->establishConnection('w'); | ||||
| echo "Trimming trailing whitespace from user real names...\n"; | echo pht('Trimming trailing whitespace from user real names...')."\n"; | ||||
| foreach (new LiskMigrationIterator($table) as $user) { | foreach (new LiskMigrationIterator($table) as $user) { | ||||
| $id = $user->getID(); | $id = $user->getID(); | ||||
| $real = $user->getRealName(); | $real = $user->getRealName(); | ||||
| $trim = rtrim($real); | $trim = rtrim($real); | ||||
| if ($trim == $real) { | if ($trim == $real) { | ||||
| echo "User {$id} is already trim.\n"; | echo pht('User %d is already trim.', $id)."\n"; | ||||
| continue; | continue; | ||||
| } | } | ||||
| echo "Trimming user {$id} from '{$real}' to '{$trim}'.\n"; | echo pht("Trimming user %d from '%s' to '%s'.", $id, $real, $trim)."\n"; | ||||
| qsprintf( | qsprintf( | ||||
| $conn_w, | $conn_w, | ||||
| 'UPDATE %T SET realName = %s WHERE id = %d', | 'UPDATE %T SET realName = %s WHERE id = %d', | ||||
| $table->getTableName(), | $table->getTableName(), | ||||
| $real, | $real, | ||||
| $id); | $id); | ||||
| } | } | ||||
| echo "Done.\n"; | echo pht('Done.')."\n"; | ||||