1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 22:40:55 +01:00

Add a missing "null" check when rebuilding old/new diff content

Summary:
See <https://discourse.phabricator-community.org/t/exceptions-when-viewing-diffs/3787>. This list may include `null` values.

Until PHP 7.4, `$x = null; echo $x['y'];` does not emit a warning. Sneaky!

Test Plan:
  - Traced `null` values from `reparseHunksForSpecialAttributes()`, saw them no longer incorporated into corpus bodies.
  - This has some amount of test coverage.

Differential Revision: https://secure.phabricator.com/D21169
This commit is contained in:
epriestley 2020-04-25 09:16:53 -07:00
parent 454ecb56e3
commit 40d2346f29

View file

@ -456,6 +456,11 @@ final class DifferentialHunkParser extends Phobject {
$corpus = array(); $corpus = array();
foreach ($lines as $l) { foreach ($lines as $l) {
if ($l === null) {
$corpus[] = "\n";
continue;
}
if ($l['type'] != '\\') { if ($l['type'] != '\\') {
if ($l['text'] === null) { if ($l['text'] === null) {
// There's no text on this side of the diff, but insert a placeholder // There's no text on this side of the diff, but insert a placeholder