@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.

Throw a proper ConduitException when trying to create an empty diff

Summary:
Avoid an ugly RuntimeException when trying to create an empty diff by bailing out early with a proper error message.
(If we were to only check if $change_data is null, we'd still end up with an empty revision created.)

```
EXCEPTION: (RuntimeException) foreach() argument must be of type array|object, null given at [<arcanist>/src/error/PhutilErrorHandler.php:270]
```

Closes T16427

Test Plan:
* PHP 8.5
* Go to http://phorge.localhost/conduit/method/differential.creatediff/
* Press the "Call Method" button

Reviewers: O1 Blessed Committers, mainframe98

Reviewed By: O1 Blessed Committers, mainframe98

Subscribers: mainframe98, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T16427

Differential Revision: https://we.phorge.it/D26638

+10
+10
src/applications/differential/conduit/DifferentialCreateDiffConduitAPIMethod.php
··· 52 52 return 'nonempty dict'; 53 53 } 54 54 55 + protected function defineErrorTypes() { 56 + return array( 57 + 'ERR-NO-CONTENT' => pht('Diff may not be empty.'), 58 + ); 59 + } 60 + 55 61 protected function execute(ConduitAPIRequest $request) { 56 62 $viewer = $request->getUser(); 57 63 $change_data = $request->getValue('changes'); 64 + 65 + if (!$change_data) { 66 + throw new ConduitException('ERR-NO-CONTENT'); 67 + } 58 68 59 69 $changes = array(); 60 70 foreach ($change_data as $dict) {