mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Raise a better error in Phame when trying to set two blogs to the same domain
Summary: Currently the exception escapes to top level. Instead, intercept it and complain. Test Plan: Tried to set two blogs to the same domain. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T1373 Differential Revision: https://secure.phabricator.com/D3701
This commit is contained in:
parent
1ecbf23e1e
commit
4de5e949ca
1 changed files with 10 additions and 5 deletions
|
@ -80,6 +80,8 @@ final class PhameBlogEditController
|
|||
|
||||
$blog->setName($name);
|
||||
$blog->setDescription($description);
|
||||
$blog->setDomain($custom_domain);
|
||||
$blog->setSkin($skin);
|
||||
|
||||
if (!empty($custom_domain)) {
|
||||
$error = $blog->validateCustomDomain($custom_domain);
|
||||
|
@ -87,9 +89,7 @@ final class PhameBlogEditController
|
|||
$errors[] = $error;
|
||||
$e_custom_domain = 'Invalid';
|
||||
}
|
||||
$blog->setDomain($custom_domain);
|
||||
}
|
||||
$blog->setSkin($skin);
|
||||
|
||||
$blog->setViewPolicy($request->getStr('can_view'));
|
||||
$blog->setEditPolicy($request->getStr('can_edit'));
|
||||
|
@ -102,9 +102,14 @@ final class PhameBlogEditController
|
|||
PhabricatorPolicyCapability::CAN_EDIT);
|
||||
|
||||
if (!$errors) {
|
||||
$blog->save();
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI($this->getApplicationURI('blog/view/'.$blog->getID().'/'));
|
||||
try {
|
||||
$blog->save();
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI($this->getApplicationURI('blog/view/'.$blog->getID().'/'));
|
||||
} catch (AphrontQueryDuplicateKeyException $ex) {
|
||||
$errors[] = 'Domain must be unique.';
|
||||
$e_custom_domain = 'Not Unique';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue