From 7cb44bcee6bf05470f64597133e0e7f425bcad0a Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 26 Oct 2016 12:35:53 -0700 Subject: [PATCH] Don't allow "Start Time" / "End Time" in Calendar event forms to be locked or have defaults assigned Summary: Fixes T11733. This fixes the issue by working around it, but it isn't useful to set these fields to a default value anyway. Test Plan: Created a default Calendar form, set some other defaults, created an event, stuff no longer exploded. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11733 Differential Revision: https://secure.phabricator.com/D16753 --- .../editor/PhabricatorCalendarEventEditEngine.php | 6 ++++++ .../storage/PhabricatorEditEngineConfiguration.php | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/src/applications/calendar/editor/PhabricatorCalendarEventEditEngine.php b/src/applications/calendar/editor/PhabricatorCalendarEventEditEngine.php index 17ea7552e9..fef14c13e1 100644 --- a/src/applications/calendar/editor/PhabricatorCalendarEventEditEngine.php +++ b/src/applications/calendar/editor/PhabricatorCalendarEventEditEngine.php @@ -164,6 +164,8 @@ final class PhabricatorCalendarEventEditEngine if ($this->getIsCreate() || $object->getIsRecurring()) { $fields[] = id(new PhabricatorEpochEditField()) + ->setIsLockable(false) + ->setIsDefaultable(false) ->setAllowNull(true) ->setKey('until') ->setLabel(pht('Repeat Until')) @@ -189,6 +191,8 @@ final class PhabricatorCalendarEventEditEngine $fields[] = id(new PhabricatorEpochEditField()) ->setKey('start') ->setLabel(pht('Start')) + ->setIsLockable(false) + ->setIsDefaultable(false) ->setTransactionType( PhabricatorCalendarEventStartDateTransaction::TRANSACTIONTYPE) ->setDescription(pht('Start time of the event.')) @@ -199,6 +203,8 @@ final class PhabricatorCalendarEventEditEngine $fields[] = id(new PhabricatorEpochEditField()) ->setKey('end') ->setLabel(pht('End')) + ->setIsLockable(false) + ->setIsDefaultable(false) ->setTransactionType( PhabricatorCalendarEventEndDateTransaction::TRANSACTIONTYPE) ->setDescription(pht('End time of the event.')) diff --git a/src/applications/transactions/storage/PhabricatorEditEngineConfiguration.php b/src/applications/transactions/storage/PhabricatorEditEngineConfiguration.php index 38a4fda0a6..e169171f98 100644 --- a/src/applications/transactions/storage/PhabricatorEditEngineConfiguration.php +++ b/src/applications/transactions/storage/PhabricatorEditEngineConfiguration.php @@ -128,6 +128,9 @@ final class PhabricatorEditEngineConfiguration $values = $this->getProperty('defaults', array()); foreach ($fields as $key => $field) { + if (!$field->getIsDefaultable()) { + continue; + } if ($is_new) { if (array_key_exists($key, $values)) { $field->readDefaultValueFromConfiguration($values[$key]); @@ -157,6 +160,11 @@ final class PhabricatorEditEngineConfiguration } } + // If the field isn't lockable, remove any lock we applied. + if (!$field->getIsLockable()) { + $field->setIsLocked(false); + } + $fields = $this->reorderFields($fields); $preamble = $this->getPreamble();