mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-23 23:32:39 +01:00
Fix PHP 8.1 null exceptions which block rendering tab panels on dashboards
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. Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15346 Differential Revision: https://we.phorge.it/D25250
This commit is contained in:
parent
8eda766990
commit
b325304b6e
2 changed files with 5 additions and 2 deletions
|
@ -481,7 +481,7 @@ class JsonLintJsonParser
|
|||
// UTF-8 ByteOrderMark sequence
|
||||
$bom = "\xEF\xBB\xBF";
|
||||
|
||||
if (substr($input, 0, 3) === $bom) {
|
||||
if ($input && (substr($input, 0, 3) === $bom)) {
|
||||
$this->parseError("BOM detected, make sure your input does not include a Unicode Byte-Order-Mark", array());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ class JsonLintLexer
|
|||
public function getUpcomingInput()
|
||||
{
|
||||
$next = $this->match;
|
||||
if (strlen($next) < 20) {
|
||||
if ($this->input !== null && strlen($next) < 20) {
|
||||
$next .= substr($this->input, 0, 20 - strlen($next));
|
||||
}
|
||||
|
||||
|
@ -128,6 +128,9 @@ class JsonLintLexer
|
|||
$rules = $this->getCurrentRules();
|
||||
$rulesLen = count($rules);
|
||||
|
||||
if (!isset($this->input)) {
|
||||
$this->input = '';
|
||||
}
|
||||
for ($i=0; $i < $rulesLen; $i++) {
|
||||
if (preg_match($this->rules[$rules[$i]], $this->input, $match)) {
|
||||
preg_match_all('/\n.*/', $match[0], $lines);
|
||||
|
|
Loading…
Reference in a new issue