@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Don't allow forms which can't create objects to be added to profile menus

Summary:
Fixes T12281. Some forms (like Settings) can't actually create new objects. Currently, though, you can select them and add them to profile menus; if you do, they fail when building an item.

Kick them out of the typeahead, and decline to render them in menus.

Test Plan:
Added "Create Settings" to a menu, no longer fatals after patch (item vanished from menu, still editable normally to get rid of it).

Tried to add another "Create Settings", no longer available in typehaead.

Added some normal stuff.

Viewed a choose-among-forms dropdown in Maniphest, which still worked normally.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12281

Differential Revision: https://secure.phabricator.com/D17372

+25 -5
+5 -3
src/applications/search/menuitem/PhabricatorEditEngineProfileMenuItem.php
··· 106 106 if (!$form) { 107 107 return array(); 108 108 } 109 - $engine = $form->getEngine(); 110 - $form_key = $form->getIdentifier(); 111 109 112 110 $icon = $form->getIcon(); 113 111 $name = $this->getDisplayName($config); 114 - $href = $engine->getEditURI(null, "form/{$form_key}/"); 112 + 113 + $href = $form->getCreateURI(); 114 + if ($href === null) { 115 + return array(); 116 + } 115 117 116 118 $item = $this->newItem() 117 119 ->setHref($href)
+1 -2
src/applications/transactions/editengine/PhabricatorEditEngine.php
··· 1489 1489 ); 1490 1490 } else { 1491 1491 foreach ($configs as $config) { 1492 - $form_key = $config->getIdentifier(); 1493 - $config_uri = $this->getEditURI(null, "form/{$form_key}/"); 1492 + $config_uri = $config->getCreateURI(); 1494 1493 1495 1494 if ($parameters) { 1496 1495 $config_uri = (string)id(new PhutilURI($config_uri))
+13
src/applications/transactions/storage/PhabricatorEditEngineConfiguration.php
··· 216 216 return "/transactions/editengine/{$engine_key}/view/{$key}/"; 217 217 } 218 218 219 + public function getCreateURI() { 220 + $form_key = $this->getIdentifier(); 221 + $engine = $this->getEngine(); 222 + 223 + try { 224 + $create_uri = $engine->getEditURI(null, "form/{$form_key}/"); 225 + } catch (Exception $ex) { 226 + $create_uri = null; 227 + } 228 + 229 + return $create_uri; 230 + } 231 + 219 232 public function getIdentifier() { 220 233 $key = $this->getID(); 221 234 if (!$key) {
+6
src/applications/transactions/typeahead/PhabricatorEditEngineDatasource.php
··· 30 30 $forms = $this->executeQuery($query); 31 31 $results = array(); 32 32 foreach ($forms as $form) { 33 + $create_uri = $form->getCreateURI(); 34 + if (!$create_uri) { 35 + continue; 36 + } 37 + 33 38 if ($form->getID()) { 34 39 $key = $form->getEngineKey().'/'.$form->getID(); 35 40 } else { 36 41 $key = $form->getEngineKey().'/'.$form->getBuiltinKey(); 37 42 } 43 + 38 44 $result = id(new PhabricatorTypeaheadResult()) 39 45 ->setName($form->getName()) 40 46 ->setPHID($key)