Page MenuHomePhorge

Fix PHP 8.1 null exceptions which block rendering tab panels on dashboards
ClosedPublic

Authored by aklapper on May 28 2023, 13:02.

Details

Summary

Passing null as input strings to substr() and preg_match() is deprecated in PHP 8.
Thus do not call substr() when input is null and pass an empty string instead of null to preg_match(). (Not calling preg_match() at all here would lead to Exception: Lexical error on line 1. Unrecognized text. ^).

Closes T15346

Test Plan

After applying these three changes and following the steps in T15346, tab on the dashboard displays "This tab panel does not have any tabs yet." as expected instead of the previous RuntimeException.

Diff Detail

Repository
rARC Arcanist
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

externals/jsonlint/src/Seld/JsonLint/JsonParser.php
484

✅ Verified. This involves a PHP pitfall but it's OK: the string "0" cannot never match the Byte Order Mark. Nice short-circuit.

externals/jsonlint/src/Seld/JsonLint/Lexer.php
97

🔶 Maybe problematic since the string "0" will be skipped and maybe it should not.

Proposed minimal change:

if ($this->input !== null && strlen($next) < 20) {
131–133

✅ Verified. This is the minimal change to have an usable non-deprecated input to be used against whatever regex rule.

Make check in getUpcomingInput() also cover string "0" (as requested by valerio.bozzolan)

This now partially overlaps with D25269

Thanks again for this patch

Hoping to be useful I will just keep the last newline as-is, but everything else seems good to me to avoid NULL/undefined. Also better than other similar patches on the same files.

lgtm

This revision is now accepted and ready to land.Jun 2 2023, 14:42

keep last newline as-is just because sometime my friends ask that