mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-17 20:32:41 +01:00
Add a repair migration to fix legacy Calendar events without "utcInstanceEpoch"
Summary: Fixes T12488. Some events appear to have survived earlier migrations without getting completely fixed. Fix them. Test Plan: - Ran migration locally with `bin/storage upgrade` (but: I could not reproduce this problem locally). - Ran migration in production and saw ICS import stop fataling. Reviewers: chad Reviewed By: chad Maniphest Tasks: T12488 Differential Revision: https://secure.phabricator.com/D17642
This commit is contained in:
parent
c9f51fd405
commit
d4d46501ed
1 changed files with 42 additions and 0 deletions
42
resources/sql/autopatches/20170410.calendar.01.repair.php
Normal file
42
resources/sql/autopatches/20170410.calendar.01.repair.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
// See T12488. Some events survived "20161004.cal.01.noepoch.php" without
|
||||
// having "utcInstanceEpoch" computed, which breaks ICS export. This appears
|
||||
// to be the result of some bug which has been fixed in the meantime, so just
|
||||
// redo this part of the migration.
|
||||
|
||||
$table = new PhabricatorCalendarEvent();
|
||||
$conn = $table->establishConnection('w');
|
||||
$table_name = $table->getTableName();
|
||||
|
||||
$viewer = PhabricatorUser::getOmnipotentUser();
|
||||
$all_events = id(new PhabricatorCalendarEventQuery())
|
||||
->setViewer($viewer)
|
||||
->execute();
|
||||
foreach ($all_events as $event) {
|
||||
$id = $event->getID();
|
||||
|
||||
if (!$event->getInstanceOfEventPHID()) {
|
||||
// Not a child event, so no instance epoch.
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($event->getUTCInstanceEpoch()) {
|
||||
// Already has an instance epoch.
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
$event->updateUTCEpochs();
|
||||
} catch (Exception $ex) {
|
||||
phlog($ex);
|
||||
continue;
|
||||
}
|
||||
|
||||
queryfx(
|
||||
$conn,
|
||||
'UPDATE %T SET utcInstanceEpoch = %nd WHERE id = %d',
|
||||
$table_name,
|
||||
$event->getUTCInstanceEpoch(),
|
||||
$id);
|
||||
}
|
Loading…
Reference in a new issue