1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-21 04:50:55 +01:00
phorge-phorge/resources/sql/autopatches/20150506.calendarunnamedevents.1.php

34 lines
799 B
PHP
Raw Normal View History

<?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";