1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 22:10:55 +01:00

Calendar - error better with invalid time values

Summary: Fixes T7665. Unfortunately when the user messes this up its not easy to partially recover so we just reset that time to the default.

Test Plan: set time to "00:00 AM" and got a sensible error.

Reviewers: chad, epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7665

Differential Revision: https://secure.phabricator.com/D12174
This commit is contained in:
Bob Trahan 2015-03-26 13:02:49 -07:00
parent 4ae28837fd
commit 871c06ab4e

View file

@ -66,16 +66,24 @@ final class PhabricatorCalendarEventEditController
$end_value = $end_time->readValueFromRequest($request);
$description = $request->getStr('description');
try {
$status
->setUserPHID($user->getPHID())
->setStatus($type)
->setDateFrom($start_value)
->setDateTo($end_value)
->setDescription($description)
->save();
} catch (PhabricatorCalendarEventInvalidEpochException $e) {
$errors[] = pht('Start must be before end.');
if ($start_time->getError()) {
$errors[] = pht('Invalid start time; reset to default.');
}
if ($end_time->getError()) {
$errors[] = pht('Invalid end time; reset to default.');
}
if (!$errors) {
try {
$status
->setUserPHID($user->getPHID())
->setStatus($type)
->setDateFrom($start_value)
->setDateTo($end_value)
->setDescription($description)
->save();
} catch (PhabricatorCalendarEventInvalidEpochException $e) {
$errors[] = pht('Start must be before end.');
}
}
if (!$errors) {