Skip to content

Commit

Permalink
Fix two bugs with Config's Edit controller.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
relrod authored and epriestley committed Dec 30, 2012
1 parent 250fe7f commit 908253f
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function processRequest() {
$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.';
Expand All @@ -53,6 +53,8 @@ public function processRequest() {
} 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);
Expand Down

0 comments on commit 908253f

Please sign in to comment.