From acd5d5ae4a39115b06bf68f62a586461485c5f1e Mon Sep 17 00:00:00 2001 From: James Rhodes Date: Sun, 8 Dec 2013 12:15:13 +1100 Subject: [PATCH] Correctly handle downloading ZIP with empty directories in Phragment Summary: This logic causes an exception because getPHID() is called on a fragment that has no latest version. This fixes the code so that in this scenario, it returns an empty array (with no path to be added to the ZIP). Test Plan: Downloaded the ZIP successfully after the patch was applied. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley CC: Korvin, epriestley, aran Maniphest Tasks: T4205 Differential Revision: https://secure.phabricator.com/D7735 --- .../phragment/controller/PhragmentZIPController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/applications/phragment/controller/PhragmentZIPController.php b/src/applications/phragment/controller/PhragmentZIPController.php index 13893cdee2..1c1f623796 100644 --- a/src/applications/phragment/controller/PhragmentZIPController.php +++ b/src/applications/phragment/controller/PhragmentZIPController.php @@ -95,6 +95,9 @@ final class PhragmentZIPController extends PhragmentController { if (count($children) === 0) { $path = substr($current->getPath(), strlen($base_path) + 1); + if ($current->getLatestVersion() === null) { + return array(); + } return array($path => $current->getLatestVersion()->getFilePHID()); } else { $mappings = array();