From 908253f1db01d3d9368cc8bccfaab3102e53cf2c Mon Sep 17 00:00:00 2001 From: Ricky Elrod Date: Sun, 30 Dec 2012 06:15:41 -0800 Subject: [PATCH] Fix two bugs with Config's Edit controller. Summary: * When we restored to the default value, we did, in fact delete the row from the database, but then a few lines later down, we saved it again. This patch causes the controller to return early on delete, like it was supposed to do to begin with. * When checking the user's input value for `null` (since PHP's JSON encoder will return `null` on failure), check the value that the user gave, not the value that we default to (which is often `null` anyway). Oops. Test Plan: * Saved an empty text field and saw the delete work properly and NOT get re-added. * Put `null` in the text field, and saved successfully. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D4300 --- .../config/controller/PhabricatorConfigEditController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/applications/config/controller/PhabricatorConfigEditController.php b/src/applications/config/controller/PhabricatorConfigEditController.php index 2145eaf416..a1b31b465e 100644 --- a/src/applications/config/controller/PhabricatorConfigEditController.php +++ b/src/applications/config/controller/PhabricatorConfigEditController.php @@ -42,7 +42,7 @@ final class PhabricatorConfigEditController $new_value = $request->getStr('value'); if (strlen($new_value)) { $json = json_decode($new_value, true); - if ($json === null && strtolower($value) != 'null') { + if ($json === null && strtolower($new_value) != 'null') { $e_value = 'Invalid'; $errors[] = 'The given value must be valid JSON. This means, among '. 'other things, that you must wrap strings in double-quotes.'; @@ -53,6 +53,8 @@ final class PhabricatorConfigEditController } else { // TODO: When we do Transactions, make this just set isDeleted = 1 $config_entry->delete(); + return id(new AphrontRedirectResponse()) + ->setURI($config_entry->getURI()); } $config_entry->setValue($value);