1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-30 09:20:58 +01:00

Project - add editor-level support for detecting name conflicts

Summary: Fixes T4833. I wish there was an elegant way to catch this exception but I think the stack is written such that we really should just do this one-off query here...

Test Plan: from the "create project" link under "edit task" I received a more detailed exception than the report in T4833 post patch. I also tested editing an existing project - yay - and editing an existing project to some other existing project's name - got a nice error dialogue.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T4833

Differential Revision: https://secure.phabricator.com/D8834
This commit is contained in:
Bob Trahan 2014-04-21 15:44:35 -07:00
parent 5cbdda413c
commit c00733a292

View file

@ -179,6 +179,25 @@ final class PhabricatorProjectTransactionEditor
$error->setIsMissingFieldError(true); $error->setIsMissingFieldError(true);
$errors[] = $error; $errors[] = $error;
} }
if (!$xactions) {
break;
}
$name = last($xactions)->getNewValue();
$name_used_already = id(new PhabricatorProjectQuery())
->setViewer($this->getActor())
->withNames(array($name))
->executeOne();
if ($name_used_already &&
($name_used_already->getPHID() != $object->getPHID())) {
$error = new PhabricatorApplicationTransactionValidationError(
$type,
pht(''),
pht('Project name is already used.'),
nonempty(last($xactions), null));
$errors[] = $error;
}
break; break;
} }