You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Lexer raises a PHP 8.6 notice on hex literals larger than PHP_INT_MAX #694
Token::extract() passes every 0x... number to hexdec(). Since PHP 8.6, hexdec() raises an E_NOTICE when the result does not fit in an integer:
Input number is larger than PHP_INT_MAX, precision has been lost in conversion
Any query with a hex literal longer than 16 digits triggers it while lexing. Such literals are common in dumps and generated SQL, for example CONVERT(0x... USING utf8mb4) for text or binary column data. Applications that turn notices into exceptions fail on these queries before parsing finishes.
PHP 8.5 returns the same float without a notice, so the value was already lossy there (5.735816763073855E+30 below). MySQL and MariaDB treat such a literal as a binary string in string context, not as a number.
PHP Notice: Input number is larger than PHP_INT_MAX, precision has been lost in conversion in vendor/phpmyadmin/sql-parser/src/Token.php on line 144
...
[TOKEN 2]
Type = 6
Flags = 1
Value = 5.735816763073855E+30
Token = '0x48656C6C6F2C20776F726C6421'
--lint triggers the same notice.
Expected behaviour
Lexing succeeds without a notice, and the token value does not pretend to be an exact number.
Affected versions
6.0.2 and the current 6.0.x and master branches, which have the same code in Token::extract().
Possible fix
Keep the token text as value when the literal is out of integer range, as is already done for FLAG_NUMBER_BINARY and FLAG_NUMBER_HEX_STRING:
The sign needs the explicit prefix: $ret has the signs stripped, so an early return $ret would turn -0x8000000000000000 into the unsigned text 0x8000000000000000.
Activity