1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-24 15:52:41 +01:00
phorge-phorge/resources/sql/autopatches/20150506.calendarunnamedevents.1.php
epriestley b6daa049de Rename Event "userPHID" to "hostPHID"
Summary: Ref T10909. Ref T9224. We label this field "Host" in the UI; make the storage format consistent.

Test Plan:
  - Viewed month view, day view, detail view of an event.
  - Created a new event, saw myself as the host.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9224, T10909

Differential Revision: https://secure.phabricator.com/D16291
2016-07-13 15:39:55 -07:00

38 lines
995 B
PHP

<?php
echo pht('Retro-naming unnamed events.')."\n";
$table = new PhabricatorCalendarEvent();
$conn_w = $table->establishConnection('w');
$iterator = new LiskMigrationIterator($table);
foreach ($iterator as $event) {
$id = $event->getID();
if (strlen($event->getName()) == 0) {
echo pht('Renaming event %d...', $id)."\n";
$viewer = PhabricatorUser::getOmnipotentUser();
// NOTE: This uses PeopleQuery directly, instead of HandleQuery, to avoid
// performing cache fills as a side effect; the caches were added by a
// later patch. See T8209.
$user = id(new PhabricatorPeopleQuery())
->setViewer($viewer)
->withPHIDs(array($event->getHostPHID()))
->executeOne();
if ($user) {
$new_name = $user->getUsername();
} else {
$new_name = pht('Unnamed Event');
}
queryfx(
$conn_w,
'UPDATE %T SET name = %s WHERE id = %d',
$table->getTableName(),
$new_name,
$id);
}
}
echo pht('Done.')."\n";