From 2188473fa77244ff0c2ab6e2c80a95bc73d8bb50 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 20 Apr 2022 09:34:00 -0700 Subject: [PATCH] Fix an issue where we may "min()" an empty array when viewing a revision with no changesets Summary: Ref T13667. When a revision's diff has no changesets (usually because Diffusion performed an automatic update with an empty commit), the UI currently tries to "min()" an empty array and fatals. Handle this case properly. Test Plan: - Created a revision with a diff with no changesets ("git commit --allow-empty" + copy-paste into web UI). - Viewed revision. - Before: "min()" fatal. - After: UI isn't perfect, but works without fataling. Subscribers: cspeckmim Maniphest Tasks: T13667 Differential Revision: https://secure.phabricator.com/D21760 --- .../engine/PhabricatorInlineCommentAdjustmentEngine.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/infrastructure/diff/engine/PhabricatorInlineCommentAdjustmentEngine.php b/src/infrastructure/diff/engine/PhabricatorInlineCommentAdjustmentEngine.php index f1888cc363..0589cc0234 100644 --- a/src/infrastructure/diff/engine/PhabricatorInlineCommentAdjustmentEngine.php +++ b/src/infrastructure/diff/engine/PhabricatorInlineCommentAdjustmentEngine.php @@ -141,9 +141,7 @@ final class PhabricatorInlineCommentAdjustmentEngine } } - // Find the smallest "new" changeset ID. We'll consider everything - // larger than this to be "newer", and everything smaller to be "older". - $first_new_id = min(mpull($new, 'getID')); + $new_id_map = mpull($new, null, 'getID'); $results = array(); foreach ($inlines as $inline) { @@ -163,7 +161,7 @@ final class PhabricatorInlineCommentAdjustmentEngine $target_id = null; - if ($changeset_id >= $first_new_id) { + if (isset($new_id_map[$changeset_id])) { $name_map = $name_map_new; $is_new = true; } else {