From 262d7b7780bd240e4819643a2d6d0a4c981ae5dc Mon Sep 17 00:00:00 2001 From: lkassianik Date: Wed, 4 Nov 2015 09:01:21 -0800 Subject: [PATCH] Check that Phurl alias is unique Summary: Ref T8992, Phurl aliases must be unique. Otherwise throw an error. Test Plan: Create two Phurl's both with alias 'asdf'. When saving second Phurl, form should show an error about the duplicate alias. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin Maniphest Tasks: T8992 Differential Revision: https://secure.phabricator.com/D14401 --- .../phurl/editor/PhabricatorPhurlURLEditor.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/applications/phurl/editor/PhabricatorPhurlURLEditor.php b/src/applications/phurl/editor/PhabricatorPhurlURLEditor.php index b7dcb7e3db..e20e811b17 100644 --- a/src/applications/phurl/editor/PhabricatorPhurlURLEditor.php +++ b/src/applications/phurl/editor/PhabricatorPhurlURLEditor.php @@ -248,5 +248,19 @@ final class PhabricatorPhurlURLEditor return $body; } + protected function didCatchDuplicateKeyException( + PhabricatorLiskDAO $object, + array $xactions, + Exception $ex) { + + $errors = array(); + $errors[] = new PhabricatorApplicationTransactionValidationError( + PhabricatorPhurlURLTransaction::TYPE_ALIAS, + pht('Duplicate'), + pht('This alias is already in use.'), + null); + + throw new PhabricatorApplicationTransactionValidationException($errors); + } }