Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13974710
D7543.id17020.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D7543.id17020.diff
View Options
Index: src/applications/harbormaster/controller/HarbormasterBuildableEditController.php
===================================================================
--- src/applications/harbormaster/controller/HarbormasterBuildableEditController.php
+++ src/applications/harbormaster/controller/HarbormasterBuildableEditController.php
@@ -41,16 +41,21 @@
->withNames(array($v_name))
->executeOne();
- if ($object instanceof DifferentialRevision) {
- throw new Exception(
- "TODO: We need to assign PHIDs to diffs before this will work.");
- } else if ($object instanceof PhabricatorRepositoryCommit) {
- $buildable
- ->setBuildablePHID($object->getPHID())
- ->setContainerPHID($object->getRepository()->getPHID());
+ if ($this->buildableAlreadyExists($object->getPHID())) {
+ $e_name = pht('Already Exists');
+ $errors[] = pht('A buildable already exists for this object.');
} else {
- $e_name = pht('Invalid');
- $errors[] = pht('Enter the name of a revision or commit.');
+ if ($object instanceof DifferentialRevision) {
+ throw new Exception(
+ "TODO: We need to assign PHIDs to diffs before this will work.");
+ } else if ($object instanceof PhabricatorRepositoryCommit) {
+ $buildable
+ ->setBuildablePHID($object->getPHID())
+ ->setContainerPHID($object->getRepository()->getPHID());
+ } else {
+ $e_name = pht('Invalid');
+ $errors[] = pht('Enter the name of a revision or commit.');
+ }
}
} else {
$e_name = pht('Required');
@@ -141,4 +146,19 @@
));
}
+ private function buildableAlreadyExists($phid) {
+ $request = $this->getRequest();
+ $viewer = $request->getUser();
+
+ $buildable = id(new HarbormasterBuildableQuery())
+ ->setViewer($viewer)
+ ->withBuildablePHIDs(array($phid))
+ ->setLimit(1)
+ ->executeOne();
+ if ($buildable) {
+ return true;
+ }
+ return false;
+ }
+
}
Index: src/applications/harbormaster/storage/HarbormasterBuildable.php
===================================================================
--- src/applications/harbormaster/storage/HarbormasterBuildable.php
+++ src/applications/harbormaster/storage/HarbormasterBuildable.php
@@ -34,6 +34,7 @@
$buildable = id(new HarbormasterBuildableQuery())
->setViewer($actor)
->withBuildablePHIDs(array($buildable_object_phid))
+ ->setLimit(1)
->executeOne();
if ($buildable) {
return $buildable;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Oct 19, 6:59 AM (4 w, 15 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6720140
Default Alt Text
D7543.id17020.diff (2 KB)
Attached To
Mode
D7543: Prevent crashes when more than one buildable for an object exists
Attached
Detach File
Event Timeline
Log In to Comment