doctrine / orm

Doctrine Object Relational Mapper (ORM)
https://www.doctrine-project.org/projects/orm.html
MIT License
9.93k stars 2.51k forks source link

Query\Parser : Trying to access array offset on value of type null #9119

Open ybenhssaien opened 3 years ago

ybenhssaien commented 3 years ago

Bug Report

Executing a simple select query return this error : request.CRITICAL: Uncaught PHP Exception ErrorException: "Notice: Trying to access array offset on value of type null" at C:\Applications\wamp64\www\application\vendor\doctrine\orm\lib\Doctrine\ORM\Query\Parser.php line 1576 {"exception":"[object] (ErrorException(code: 0): Notice: Trying to access array offset on value of type null at C:\\Applications\\wamp64\\www\\application\\vendor\\doctrine\\orm\\lib\\Doctrine\\ORM\\Query\\Parser.php:1576)"} []

Q A
BC Break no
Version 2.9.5

Summary

Since the Lexer::$lookahead property is nullable, we should have a check on this line https://github.com/doctrine/orm/blob/2.10.x/lib/Doctrine/ORM/Query/Parser.php#L1562 (and maybe others !) (the same code remains in the last version)

An old merge request fix the same bug in another file : https://github.com/doctrine/orm/pull/7934/files

Current behavior

How to reproduce

Expected behavior

derrabus commented 3 years ago

Thank you. Would you like to contribute a PR for 2.10.x that fixes this issue along with a test that reproduces the problem?