From f12dbe36d603f0f4fef65f007e4323b246ddabc2 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 9 Jan 2013 08:14:17 -0800 Subject: [PATCH] Raise a better error when a file upload fails in Differential Summary: Ref T2296. If a file upload fails (e.g., too large), we read the textarea from the "Create New Diff" interface. This means we show the user an error like "empty diff" when we should show them an error like "file upload failed, patch is too large". This is part of the issue in T2296, which features a 2.5MB diff. Instead, check if a file was specified, so we'll raise a better error. Test Plan: Tried to upload a large patch, got a "file is too large" error instead of an empty-diff-related error. Reviewers: btrahan, vrana, codeblock Reviewed By: codeblock CC: aran Maniphest Tasks: T2296 Differential Revision: https://secure.phabricator.com/D4369 --- .../controller/DifferentialDiffCreateController.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/applications/differential/controller/DifferentialDiffCreateController.php b/src/applications/differential/controller/DifferentialDiffCreateController.php index 3450f20203..69e8faf8c8 100644 --- a/src/applications/differential/controller/DifferentialDiffCreateController.php +++ b/src/applications/differential/controller/DifferentialDiffCreateController.php @@ -8,9 +8,10 @@ final class DifferentialDiffCreateController extends DifferentialController { if ($request->isFormPost()) { $diff = null; - try { + + if ($request->getFileExists('diff-file')) { $diff = PhabricatorFile::readUploadedFileData($_FILES['diff-file']); - } catch (Exception $ex) { + } else { $diff = $request->getStr('diff'); }