diff --git a/src/applications/calendar/import/PhabricatorCalendarImportEngine.php b/src/applications/calendar/import/PhabricatorCalendarImportEngine.php --- a/src/applications/calendar/import/PhabricatorCalendarImportEngine.php +++ b/src/applications/calendar/import/PhabricatorCalendarImportEngine.php @@ -526,7 +526,7 @@ ->setStartDateTime($start_datetime) ->setEndDateTime($end_datetime); - $event->setIsAllDay($start_datetime->getIsAllDay()); + $event->setIsAllDay((int)$start_datetime->getIsAllDay()); // TODO: This should be transactional, but the transaction only accepts // simple frequency rules right now. @@ -551,11 +551,18 @@ PhabricatorUser $viewer, PhabricatorCalendarImport $import) { - $any_event = id(new PhabricatorCalendarEventQuery()) - ->setViewer($viewer) - ->withImportSourcePHIDs(array($import->getPHID())) - ->setLimit(1) - ->execute(); + $table = new PhabricatorCalendarEvent(); + $conn = $table->establishConnection('r'); + + // Using a CalendarEventQuery here was failing oddly in a way that was + // difficult to reproduce locally (see T11808). Just check the table + // directly; this is significantly more efficient anyway. + + $any_event = queryfx_all( + $conn, + 'SELECT phid FROM %T WHERE importSourcePHID = %s LIMIT 1', + $table->getTableName(), + $import->getPHID()); return (bool)$any_event; } diff --git a/src/applications/calendar/query/PhabricatorCalendarEventQuery.php b/src/applications/calendar/query/PhabricatorCalendarEventQuery.php --- a/src/applications/calendar/query/PhabricatorCalendarEventQuery.php +++ b/src/applications/calendar/query/PhabricatorCalendarEventQuery.php @@ -126,7 +126,7 @@ return array( 'start' => array( 'table' => $this->getPrimaryTableAlias(), - 'column' => 'dateFrom', + 'column' => 'utcInitialEpoch', 'reverse' => true, 'type' => 'int', 'unique' => false,