Changeset View
Changeset View
Standalone View
Standalone View
resources/sql/autopatches/20140815.cancdncase.php
| <?php | <?php | ||||
| // This corrects files which incorrectly had a 'cancdn' property written; | // This corrects files which incorrectly had a 'cancdn' property written; | ||||
| // the property should be 'canCDN'. | // the property should be 'canCDN'. | ||||
| $table = new PhabricatorFile(); | $table = new PhabricatorFile(); | ||||
| $conn_w = $table->establishConnection('w'); | $conn_w = $table->establishConnection('w'); | ||||
| foreach (new LiskMigrationIterator($table) as $file) { | foreach (new LiskMigrationIterator($table) as $file) { | ||||
| $id = $file->getID(); | $id = $file->getID(); | ||||
| echo "Updating capitalization of canCDN property for file {$id}...\n"; | echo pht( | ||||
| "Updating capitalization of %s property for file %d...\n", | |||||
| 'canCDN', | |||||
| $id); | |||||
| $meta = $file->getMetadata(); | $meta = $file->getMetadata(); | ||||
| if (isset($meta['cancdn'])) { | if (isset($meta['cancdn'])) { | ||||
| $meta['canCDN'] = $meta['cancdn']; | $meta['canCDN'] = $meta['cancdn']; | ||||
| unset($meta['cancdn']); | unset($meta['cancdn']); | ||||
| queryfx( | queryfx( | ||||
| $conn_w, | $conn_w, | ||||
| 'UPDATE %T SET metadata = %s WHERE id = %d', | 'UPDATE %T SET metadata = %s WHERE id = %d', | ||||
| $table->getTableName(), | $table->getTableName(), | ||||
| json_encode($meta), | json_encode($meta), | ||||
| $id); | $id); | ||||
| } | } | ||||
| } | } | ||||