Changeset View
Changeset View
Standalone View
Standalone View
resources/sql/autopatches/20140218.passwords.4.vcs.php
| <?php | <?php | ||||
| $table = new PhabricatorRepositoryVCSPassword(); | $table = new PhabricatorRepositoryVCSPassword(); | ||||
| $conn_w = $table->establishConnection('w'); | $conn_w = $table->establishConnection('w'); | ||||
| echo "Upgrading password hashing for VCS passwords.\n"; | echo pht('Upgrading password hashing for VCS passwords.')."\n"; | ||||
| $best_hasher = PhabricatorPasswordHasher::getBestHasher(); | $best_hasher = PhabricatorPasswordHasher::getBestHasher(); | ||||
| foreach (new LiskMigrationIterator($table) as $password) { | foreach (new LiskMigrationIterator($table) as $password) { | ||||
| $id = $password->getID(); | $id = $password->getID(); | ||||
| echo "Migrating VCS password {$id}...\n"; | echo pht('Migrating VCS password %d...', $id)."\n"; | ||||
| $input_hash = $password->getPasswordHash(); | $input_hash = $password->getPasswordHash(); | ||||
| $input_envelope = new PhutilOpaqueEnvelope($input_hash); | $input_envelope = new PhutilOpaqueEnvelope($input_hash); | ||||
| $storage_hash = $best_hasher->getPasswordHashForStorage($input_envelope); | $storage_hash = $best_hasher->getPasswordHashForStorage($input_envelope); | ||||
| queryfx( | queryfx( | ||||
| $conn_w, | $conn_w, | ||||
| 'UPDATE %T SET passwordHash = %s WHERE id = %d', | 'UPDATE %T SET passwordHash = %s WHERE id = %d', | ||||
| $table->getTableName(), | $table->getTableName(), | ||||
| $storage_hash->openEnvelope(), | $storage_hash->openEnvelope(), | ||||
| $id); | $id); | ||||
| } | } | ||||
| echo "Done.\n"; | echo pht('Done.')."\n"; | ||||