PHP 8.3 error suppression

PHP 8.3 has shortened the array access on null error message to "Trying to
access array offset on null". This commit changes the regular expression
used to circumvent errors.
This commit is contained in:
Sneda8 2023-12-17 01:36:25 +01:00 committed by Alexandre Rossi
parent 8bcb334146
commit 28d9543c14
No known key found for this signature in database
GPG key ID: 588F9EBA938A168F
2 changed files with 3 additions and 2 deletions

View file

@ -1,6 +1,6 @@
<?php
function adminer_errors($errno, $errstr) {
return !!preg_match('~^(Trying to access array offset on value of type null|Undefined array key)~', $errstr);
return !!preg_match('~^(Trying to access array offset on( value of type)? null|Undefined array key)~', $errstr);
}
error_reporting(6135); // errors and warnings

View file

@ -251,7 +251,8 @@ function php_shrink($input) {
if (!is_array($token)) {
$token = array(0, $token);
}
if ($tokens[$i+2][0] === T_CLOSE_TAG && $tokens[$i+3][0] === T_INLINE_HTML && $tokens[$i+4][0] === T_OPEN_TAG
if (!is_null($tokens[$i+2])
&& $tokens[$i+2][0] === T_CLOSE_TAG && $tokens[$i+3][0] === T_INLINE_HTML && $tokens[$i+4][0] === T_OPEN_TAG
&& strlen(add_apo_slashes($tokens[$i+3][1])) < strlen($tokens[$i+3][1]) + 3
) {
$tokens[$i+2] = array(T_ECHO, 'echo');