1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 21:02:41 +01:00
phorge-phorge/resources/sql/autopatches/20150506.calendarunnamedevents.1.php
lkassianik bcf60f1b05 Calendar event detail view should show "Unnamed Event" as title for events with no title
Summary: Closes T8048, Calendar event detail view should show "Unnamed Event" as title for events with no title

Test Plan: Open an old event created before titles were required, event detail view should display title as "Unnamed Event" instead of a blank title

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T8048

Differential Revision: https://secure.phabricator.com/D12736
2015-05-06 11:11:38 -07:00

33 lines
799 B
PHP

<?php
echo "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 "Renaming event {$id}...\n";
$viewer = PhabricatorUser::getOmnipotentUser();
$handle = id(new PhabricatorHandleQuery())
->setViewer($viewer)
->withPHIDs(array($event->getUserPHID()))
->executeOne();
if ($handle->isComplete()) {
$new_name = $handle->getName();
} else {
$new_name = pht('Unnamed Event');
}
queryfx(
$conn_w,
'UPDATE %T SET name = %s WHERE id = %d',
$table->getTableName(),
$new_name,
$id);
}
}
echo "Done.\n";