From 84c57f5e5751ace38b1423b7d7296438bf0a6692 Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Wed, 1 May 2024 18:51:50 +0200 Subject: [PATCH] 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 [/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 --- .../export/engine/PhabricatorProjectsExportEngineExtension.php | 3 +++ .../engine/PhabricatorSubscriptionsExportEngineExtension.php | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/infrastructure/export/engine/PhabricatorProjectsExportEngineExtension.php b/src/infrastructure/export/engine/PhabricatorProjectsExportEngineExtension.php index eb3bca3a49..24e4930714 100644 --- a/src/infrastructure/export/engine/PhabricatorProjectsExportEngineExtension.php +++ b/src/infrastructure/export/engine/PhabricatorProjectsExportEngineExtension.php @@ -24,6 +24,9 @@ final class PhabricatorProjectsExportEngineExtension $viewer = $this->getViewer(); $object_phids = mpull($objects, 'getPHID'); + if (!$object_phids) { + return array(); + } $projects_query = id(new PhabricatorEdgeQuery()) ->withSourcePHIDs($object_phids) diff --git a/src/infrastructure/export/engine/PhabricatorSubscriptionsExportEngineExtension.php b/src/infrastructure/export/engine/PhabricatorSubscriptionsExportEngineExtension.php index 8aedb38fa8..be642ae3b4 100644 --- a/src/infrastructure/export/engine/PhabricatorSubscriptionsExportEngineExtension.php +++ b/src/infrastructure/export/engine/PhabricatorSubscriptionsExportEngineExtension.php @@ -24,6 +24,9 @@ final class PhabricatorSubscriptionsExportEngineExtension $viewer = $this->getViewer(); $object_phids = mpull($objects, 'getPHID'); + if (!$object_phids) { + return array(); + } $projects_query = id(new PhabricatorEdgeQuery()) ->withSourcePHIDs($object_phids)