Changeset View
Changeset View
Standalone View
Standalone View
resources/sql/autopatches/20160720.calendar.invitetxn.php
- This file was added.
<?php | |||||
$table = new PhabricatorCalendarEventTransaction(); | |||||
$conn_w = $table->establishConnection('w'); | |||||
echo pht( | |||||
"Restructuring calendar invite transactions...\n"); | |||||
epriestley: "Restructring" missing a "u" I think? | |||||
foreach (new LiskMigrationIterator($table) as $txn) { | |||||
$type = PhabricatorCalendarEventInviteTransaction::TRANSACTIONTYPE; | |||||
if ($txn->getTransactionType() != $type) { | |||||
continue; | |||||
} | |||||
$old_value = array_keys($txn->getOldValue()); | |||||
$orig_new = $txn->getNewValue(); | |||||
$status_uninvited = 'uninvited'; | |||||
foreach ($orig_new as $key => $status) { | |||||
if ($status == $status_uninvited) { | |||||
unset($orig_new[$key]); | |||||
} | |||||
} | |||||
$new_value = array_keys($orig_new); | |||||
queryfx( | |||||
$conn_w, | |||||
Not Done Inline ActionsPrefer phutil_json_encode(), which throws if the value isn't encodable (e.g., invalid UTF8). epriestley: Prefer `phutil_json_encode()`, which throws if the value isn't encodable (e.g., invalid UTF8). | |||||
'UPDATE %T SET '. | |||||
'oldValue = %s, newValue = %s'. | |||||
'WHERE id = %d', | |||||
$table->getTableName(), | |||||
phutil_json_encode($old_value), | |||||
phutil_json_encode($new_value), | |||||
$txn->getID()); | |||||
} | |||||
echo pht('Done.')."\n"; | |||||
Not Done Inline ActionsConsider inlining this code: these functions will exist at global scope for all time, and collide with other functions named update_old_value() and update_new_value() in the future. IDEs may identify these as functions for autocomplete when there is a ~0% chance any user ever intends to type them, etc. epriestley: Consider inlining this code: these functions will exist at global scope for all time, and… |
"Restructring" missing a "u" I think?