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

Fix exception trying to export empty task list to CSV

Summary:
Check that we have objects with PHIDs before running a query. If there are none, return an empty array instead.

```
EXCEPTION: (Exception) Edge list passed to "withSourcePHIDs(...)" is empty, but it must be nonempty. at [<phorge>/src/infrastructure/edges/query/PhabricatorEdgeQuery.php:50]
```

Closes T15789

Test Plan:
* Log into Phorge, go to http://phorge.localhost/maniphest/query/assigned/ and make sure you have zero assigned tasks.
* Click "Use Results" and select "Export Data".
* In the "Export Results" dialog, keep default Format = csv and click "Download Data".
* After applying the patch, get the expected dialog "Download File - Download file assigned.csv (264 B)?" and resulting file with only column headers and no data, instead of an unhandled exception.

Reviewers: O1 Blessed Committers, speck

Reviewed By: O1 Blessed Committers, speck

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

Maniphest Tasks: T15789

Differential Revision: https://we.phorge.it/D25613
This commit is contained in:
Andre Klapper 2024-05-01 18:51:50 +02:00
parent 279ed1ee76
commit 84c57f5e57
2 changed files with 6 additions and 0 deletions

View file

@ -24,6 +24,9 @@ final class PhabricatorProjectsExportEngineExtension
$viewer = $this->getViewer(); $viewer = $this->getViewer();
$object_phids = mpull($objects, 'getPHID'); $object_phids = mpull($objects, 'getPHID');
if (!$object_phids) {
return array();
}
$projects_query = id(new PhabricatorEdgeQuery()) $projects_query = id(new PhabricatorEdgeQuery())
->withSourcePHIDs($object_phids) ->withSourcePHIDs($object_phids)

View file

@ -24,6 +24,9 @@ final class PhabricatorSubscriptionsExportEngineExtension
$viewer = $this->getViewer(); $viewer = $this->getViewer();
$object_phids = mpull($objects, 'getPHID'); $object_phids = mpull($objects, 'getPHID');
if (!$object_phids) {
return array();
}
$projects_query = id(new PhabricatorEdgeQuery()) $projects_query = id(new PhabricatorEdgeQuery())
->withSourcePHIDs($object_phids) ->withSourcePHIDs($object_phids)