1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 23:02:42 +01:00

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
This commit is contained in:
epriestley 2022-04-20 09:34:00 -07:00
parent 52df4ff515
commit 2188473fa7

View file

@ -141,9 +141,7 @@ final class PhabricatorInlineCommentAdjustmentEngine
} }
} }
// Find the smallest "new" changeset ID. We'll consider everything $new_id_map = mpull($new, null, 'getID');
// larger than this to be "newer", and everything smaller to be "older".
$first_new_id = min(mpull($new, 'getID'));
$results = array(); $results = array();
foreach ($inlines as $inline) { foreach ($inlines as $inline) {
@ -163,7 +161,7 @@ final class PhabricatorInlineCommentAdjustmentEngine
$target_id = null; $target_id = null;
if ($changeset_id >= $first_new_id) { if (isset($new_id_map[$changeset_id])) {
$name_map = $name_map_new; $name_map = $name_map_new;
$is_new = true; $is_new = true;
} else { } else {