From 237ca095a6b94ca5d5ef39b88d986e15213fc54b Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 11 Jul 2013 10:10:06 -0700 Subject: [PATCH] Trim trailing whitespace from user realnames 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 --- .../sql/patches/20130711.trimrealnames.php | 26 +++++++++++++++++++ src/__celerity_resource_map__.php | 2 +- src/__phutil_library_map__.php | 2 -- .../patch/PhabricatorBuiltinPatchList.php | 4 +++ 4 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 resources/sql/patches/20130711.trimrealnames.php diff --git a/resources/sql/patches/20130711.trimrealnames.php b/resources/sql/patches/20130711.trimrealnames.php new file mode 100644 index 0000000000..c422565b32 --- /dev/null +++ b/resources/sql/patches/20130711.trimrealnames.php @@ -0,0 +1,26 @@ +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"; diff --git a/src/__celerity_resource_map__.php b/src/__celerity_resource_map__.php index 8467f23eb5..a5d5c30144 100644 --- a/src/__celerity_resource_map__.php +++ b/src/__celerity_resource_map__.php @@ -2235,7 +2235,7 @@ celerity_register_resource_map(array( ), 'javelin-behavior-pholio-mock-view' => array( - 'uri' => '/res/983e2e81/rsrc/js/application/pholio/behavior-pholio-mock-view.js', + 'uri' => '/res/014eb2bd/rsrc/js/application/pholio/behavior-pholio-mock-view.js', 'type' => 'js', 'requires' => array( diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 50d884bcf2..d2fd18908c 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1253,7 +1253,6 @@ phutil_register_library_map(array( 'PhabricatorMetaMTAReceivedMailProcessingException' => 'applications/metamta/exception/PhabricatorMetaMTAReceivedMailProcessingException.php', 'PhabricatorMetaMTAReceivedMailTestCase' => 'applications/metamta/storage/__tests__/PhabricatorMetaMTAReceivedMailTestCase.php', 'PhabricatorMetaMTASendGridReceiveController' => 'applications/metamta/controller/PhabricatorMetaMTASendGridReceiveController.php', - 'PhabricatorMetaMTAViewController' => 'applications/metamta/controller/PhabricatorMetaMTAViewController.php', 'PhabricatorMetaMTAWorker' => 'applications/metamta/PhabricatorMetaMTAWorker.php', 'PhabricatorMultiColumnExample' => 'applications/uiexample/examples/PhabricatorMultiColumnExample.php', 'PhabricatorMustVerifyEmailController' => 'applications/auth/controller/PhabricatorMustVerifyEmailController.php', @@ -3201,7 +3200,6 @@ phutil_register_library_map(array( 'PhabricatorMetaMTAReceivedMailProcessingException' => 'Exception', 'PhabricatorMetaMTAReceivedMailTestCase' => 'PhabricatorTestCase', 'PhabricatorMetaMTASendGridReceiveController' => 'PhabricatorMetaMTAController', - 'PhabricatorMetaMTAViewController' => 'PhabricatorMetaMTAController', 'PhabricatorMetaMTAWorker' => 'PhabricatorWorker', 'PhabricatorMultiColumnExample' => 'PhabricatorUIExample', 'PhabricatorMustVerifyEmailController' => 'PhabricatorAuthController', diff --git a/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php b/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php index db8daf6016..9992ec28e0 100644 --- a/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php +++ b/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php @@ -1438,6 +1438,10 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList { 'type' => 'sql', 'name' => $this->getPatchPath('20130709.droptimeline.sql'), ), + '20130711.trimrealnames.php' => array( + 'type' => 'php', + 'name' => $this->getPatchPath('20130711.trimrealnames.php'), + ), ); } }