mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 22:10:55 +01:00
27b78d2147
Summary: Fixes T8209. Using handles can now cause cache fills as a side effect of T7707. Use a raw query instead. I'll follow up on T8209 with some context and ideas for longer-term fixes. Test Plan: - Set event names to `''`. - Reran migration with `--apply ... --trace`. - Saw migration work correctly without executing cache fills. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T8209 Differential Revision: https://secure.phabricator.com/D12858
38 lines
969 B
PHP
38 lines
969 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();
|
|
|
|
// 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->getUserPHID()))
|
|
->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 "Done.\n";
|