1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 06:42:42 +01:00

Fix exception accessing a non-existing EditEngine

Summary:
Trying to access a non-existing edit engine "foo" via the URI `/transactions/editengine/foo/` throws an unhandled exception.
`PhabricatorEditEngine::getByKey($viewer, $engine_key)` is null as `$engine_key` is non-existing `foo`.
Thus avoid calling `setViewer()` on `null` by splitting into a separate step after a null check.
When null, show a proper 404 error instead.

```
EXCEPTION: (Error) Call to a member function setViewer() on null at [<phorge>/src/applications/transactions/controller/PhabricatorEditEngineConfigurationListController.php:17]
```

Closes T15793

Test Plan:
While logged in and with sufficient permissions,
* go to non-existing http://phorge.localhost/transactions/editengine/whatever/ before and after applying patch,
* go to existing http://phorge.localhost/transactions/editengine/maniphest.task/ to see that existing stuff still works.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15793

Differential Revision: https://we.phorge.it/D25597
This commit is contained in:
Andre Klapper 2024-04-19 12:57:07 +02:00
parent 93c7444d5c
commit 4da88848be

View file

@ -13,12 +13,11 @@ final class PhabricatorEditEngineConfigurationListController
$engine_key = $request->getURIData('engineKey');
$this->setEngineKey($engine_key);
$engine = PhabricatorEditEngine::getByKey($viewer, $engine_key)
->setViewer($viewer);
if (!$engine->isEngineConfigurable()) {
$engine = PhabricatorEditEngine::getByKey($viewer, $engine_key);
if (!$engine || !$engine->isEngineConfigurable()) {
return new Aphront404Response();
}
$engine->setViewer($viewer);
$items = array();
$items[] = id(new PHUIListItemView())