From 09151b509e1ef815e085d5aef20274d51037b04f Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 17 Oct 2012 15:13:03 -0700 Subject: [PATCH] Raise a better error for trying to create an empty document in Phriction Summary: When you delete the content of a document in Phriction, we treat it as an attempt to delete the document. In the case you're creating the document, we hit an exception trying to delete a document which doesn't exist yet. Detect this case and raise a better error. Test Plan: Tried to create an empty document, got a good error. Created a nonempty document. Edited a document to empty to delete it. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T1920 Differential Revision: https://secure.phabricator.com/D3728 --- .../controller/PhrictionEditController.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/applications/phriction/controller/PhrictionEditController.php b/src/applications/phriction/controller/PhrictionEditController.php index 79b9188681..9e7c351417 100644 --- a/src/applications/phriction/controller/PhrictionEditController.php +++ b/src/applications/phriction/controller/PhrictionEditController.php @@ -130,6 +130,19 @@ final class PhrictionEditController return id(new AphrontDialogResponse())->setDialog($dialog); } + } else if (!strlen($request->getStr('content'))) { + + // We trigger this only for new pages. For existing pages, deleting + // all the content counts as deleting the page. + + $dialog = new AphrontDialogView(); + $dialog->setUser($user); + $dialog->setTitle('Empty Page'); + $dialog->appendChild( + '

You can not create an empty document.

'); + $dialog->addCancelButton($request->getRequestURI()); + + return id(new AphrontDialogResponse())->setDialog($dialog); } if (!count($errors)) {