2.18.x: Lexer not longer implementing ArrayAccess #7305

Closed
opened 2026-01-22 15:49:37 +01:00 by admin · 6 comments
Owner

Originally created by @alexander-schranz on GitHub (Jan 28, 2024).

BC Break Report

Q A
BC Break yes
Version 2.18.x

Summary

The oro/doctrine-extensions is using the Doctrine\ORM\Query\Lexer, with adding support for doctrine/lexer version 3 in 2.18 of doctrine/orm the Doctrine\ORM\Query\Lexer not longer implements the ArrayAccess which leads to an unexpected error.

Update: its the Token class which is not longer implementing the ArrayAccess. Maybe we need to make sure that all doctrine extensions require the correct supported lexer version before we release 2.18.0. So no changes maybe require to fix this issue in orm package.

Previous behavior

ArrayAccess was implemented by Doctrine\ORM\Query\Lexer over the doctrine/lexer:2 package. doctrine/lexer:2 was installed which Token implemented the ArrayAccess.

Current behavior

ArrayAccess is not longer implemented which ends in:

/home/runner/work/sulu/sulu/vendor/oro/doctrine-extensions/src/Oro/ORM/Query/AST/Functions/String/GroupConcat.php:46
/home/runner/work/sulu/sulu/vendor/doctrine/orm/src/Query/Parser.php:3662
/home/runner/work/sulu/sulu/vendor/doctrine/orm/src/Query/Parser.php:3526
/home/runner/work/sulu/sulu/vendor/doctrine/orm/src/Query/Parser.php:3491
/home/runner/work/sulu/sulu/vendor/doctrine/orm/src/Query/Parser.php:2273
/home/runner/work/sulu/sulu/vendor/doctrine/orm/src/Query/Parser.php:1217
/home/runner/work/sulu/sulu/vendor/doctrine/orm/src/Query/Parser.php:881
/home/runner/work/sulu/sulu/vendor/doctrine/orm/src/Query/Parser.php:850
/home/runner/work/sulu/sulu/vendor/doctrine/orm/src/Query/Parser.php:257
/home/runner/work/sulu/sulu/vendor/doctrine/orm/src/Query/Parser.php:357
/home/runner/work/sulu/sulu/vendor/doctrine/orm/src/Query.php:276
/home/runner/work/sulu/sulu/vendor/doctrine/orm/src/Query.php:288
/home/runner/work/sulu/sulu/vendor/doctrine/orm/src/AbstractQuery.php:1212
/home/runner/work/sulu/sulu/vendor/doctrine/orm/src/AbstractQuery.php:1166
/home/runner/work/sulu/sulu/vendor/doctrine/orm/src/AbstractQuery.php:913
/home/runner/work/sulu/sulu/src/Sulu/Component/Rest/ListBuilder/Doctrine/DoctrineListBuilder.php:297
/home/runner/work/sulu/sulu/src/Sulu/Bundle/ContactBundle/Controller/ContactController.php:340
/home/runner/work/sulu/sulu/src/Sulu/Bundle/ContactBundle/Controller/ContactController.php:318
/home/runner/work/sulu/sulu/src/Sulu/Bundle/ContactBundle/Controller/ContactController.php:262
/home/runner/work/sulu/sulu/vendor/symfony/http-kernel/HttpKernel.php:181
/home/runner/work/sulu/sulu/vendor/symfony/http-kernel/HttpKernel.php:76
/home/runner/work/sulu/sulu/vendor/symfony/http-kernel/Kernel.php:197
/home/runner/work/sulu/sulu/vendor/symfony/http-kernel/HttpKernelBrowser.php:65
/home/runner/work/sulu/sulu/vendor/symfony/framework-bundle/KernelBrowser.php:175
/home/runner/work/sulu/sulu/vendor/symfony/browser-kit/AbstractBrowser.php:385
/home/runner/work/sulu/sulu/src/Sulu/Bundle/TestBundle/Kernel/SuluKernelBrowser.php:57
/home/runner/work/sulu/sulu/src/Sulu/Bundle/ContactBundle/Tests/Functional/Controller/AccountControllerTest.php:1532

How to reproduce

Using GroupConcat of oro/doctrine-extensions. As they never directly u se the doctrine/lexer namespace just the doctrine/orm namespace it is unexpected that in the minor jump the Orm/Lexer not longer shipped with ArrayAccess. So we maybe need to implement the ArrayAccess for the doctrine/orm Lexer and remove it then in doctrine/orm 3 to avoid this bc break.

Originally created by @alexander-schranz on GitHub (Jan 28, 2024). ### BC Break Report <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |------------ | ------ | BC Break | yes | Version | 2.18.x #### Summary ~~The `oro/doctrine-extensions` is using the `Doctrine\ORM\Query\Lexer`, with adding support for `doctrine/lexer` version 3 in 2.18 of doctrine/orm the `Doctrine\ORM\Query\Lexer` not longer implements the ArrayAccess which leads to an unexpected error.~~ **Update**: its the `Token` class which is not longer implementing the ArrayAccess. Maybe we need to make sure that all doctrine extensions require the correct supported lexer version before we release 2.18.0. So no changes maybe require to fix this issue in orm package. #### Previous behavior ~~ArrayAccess was implemented by `Doctrine\ORM\Query\Lexer` over the `doctrine/lexer:2` package.~~ `doctrine/lexer:2` was installed which Token implemented the ArrayAccess. #### Current behavior ArrayAccess is not longer implemented which ends in: ``` /home/runner/work/sulu/sulu/vendor/oro/doctrine-extensions/src/Oro/ORM/Query/AST/Functions/String/GroupConcat.php:46 /home/runner/work/sulu/sulu/vendor/doctrine/orm/src/Query/Parser.php:3662 /home/runner/work/sulu/sulu/vendor/doctrine/orm/src/Query/Parser.php:3526 /home/runner/work/sulu/sulu/vendor/doctrine/orm/src/Query/Parser.php:3491 /home/runner/work/sulu/sulu/vendor/doctrine/orm/src/Query/Parser.php:2273 /home/runner/work/sulu/sulu/vendor/doctrine/orm/src/Query/Parser.php:1217 /home/runner/work/sulu/sulu/vendor/doctrine/orm/src/Query/Parser.php:881 /home/runner/work/sulu/sulu/vendor/doctrine/orm/src/Query/Parser.php:850 /home/runner/work/sulu/sulu/vendor/doctrine/orm/src/Query/Parser.php:257 /home/runner/work/sulu/sulu/vendor/doctrine/orm/src/Query/Parser.php:357 /home/runner/work/sulu/sulu/vendor/doctrine/orm/src/Query.php:276 /home/runner/work/sulu/sulu/vendor/doctrine/orm/src/Query.php:288 /home/runner/work/sulu/sulu/vendor/doctrine/orm/src/AbstractQuery.php:1212 /home/runner/work/sulu/sulu/vendor/doctrine/orm/src/AbstractQuery.php:1166 /home/runner/work/sulu/sulu/vendor/doctrine/orm/src/AbstractQuery.php:913 /home/runner/work/sulu/sulu/src/Sulu/Component/Rest/ListBuilder/Doctrine/DoctrineListBuilder.php:297 /home/runner/work/sulu/sulu/src/Sulu/Bundle/ContactBundle/Controller/ContactController.php:340 /home/runner/work/sulu/sulu/src/Sulu/Bundle/ContactBundle/Controller/ContactController.php:318 /home/runner/work/sulu/sulu/src/Sulu/Bundle/ContactBundle/Controller/ContactController.php:262 /home/runner/work/sulu/sulu/vendor/symfony/http-kernel/HttpKernel.php:181 /home/runner/work/sulu/sulu/vendor/symfony/http-kernel/HttpKernel.php:76 /home/runner/work/sulu/sulu/vendor/symfony/http-kernel/Kernel.php:197 /home/runner/work/sulu/sulu/vendor/symfony/http-kernel/HttpKernelBrowser.php:65 /home/runner/work/sulu/sulu/vendor/symfony/framework-bundle/KernelBrowser.php:175 /home/runner/work/sulu/sulu/vendor/symfony/browser-kit/AbstractBrowser.php:385 /home/runner/work/sulu/sulu/src/Sulu/Bundle/TestBundle/Kernel/SuluKernelBrowser.php:57 /home/runner/work/sulu/sulu/src/Sulu/Bundle/ContactBundle/Tests/Functional/Controller/AccountControllerTest.php:1532 ``` #### How to reproduce Using GroupConcat of oro/doctrine-extensions. As they never directly u se the `doctrine/lexer` namespace just the `doctrine/orm` namespace it is unexpected that in the minor jump the Orm/Lexer not longer shipped with ArrayAccess. So we maybe need to implement the ArrayAccess for the `doctrine/orm` Lexer and remove it then in doctrine/orm 3 to avoid this bc break.
admin closed this issue 2026-01-22 15:49:38 +01:00
Author
Owner

@greg0ire commented on GitHub (Jan 28, 2024):

So we maybe need to implement the ArrayAccess for the doctrine/orm Lexer and remove it then in doctrine/orm 3 to avoid this bc break.

Ah yes, that seems fair. In https://github.com/doctrine/orm/pull/11180#issuecomment-1903364350, @derrabus was wondering why didn't allow doctrine/lexer 3 sooner. This must be the answer. That being said, I don't think how you could implement ArrayAccess in doctrine/orm 2. There is no class to implement it on, as we use the doctrine/lexer Token class directly. I think we should probably revert.

@greg0ire commented on GitHub (Jan 28, 2024): > So we maybe need to implement the ArrayAccess for the doctrine/orm Lexer and remove it then in doctrine/orm 3 to avoid this bc break. Ah yes, that seems fair. In https://github.com/doctrine/orm/pull/11180#issuecomment-1903364350, @derrabus was wondering why didn't allow `doctrine/lexer` 3 sooner. This must be the answer. That being said, I don't think how you could implement `ArrayAccess` in `doctrine/orm` 2. There is no class to implement it on, as we use the `doctrine/lexer` Token class directly. I think we should probably revert.
Author
Owner

@greg0ire commented on GitHub (Jan 28, 2024):

@alexander-schranz actually, I'm not sure we should revert. I think the crash is happening here, correct: https://github.com/oroinc/doctrine-extensions/blob/2.0.3/src/Oro/ORM/Query/AST/Functions/String/GroupConcat.php#L46 ?

The class in doctrine/orm is not the one exposing the lookahead property. The class doing that is Doctrine\Common\Lexer\AbstractLexer. This probably means oro/doctrine-extensions should indeed specify a version constraint for doctrine/lexer.

@greg0ire commented on GitHub (Jan 28, 2024): @alexander-schranz actually, I'm not sure we should revert. I think the crash is happening here, correct: https://github.com/oroinc/doctrine-extensions/blob/2.0.3/src/Oro/ORM/Query/AST/Functions/String/GroupConcat.php#L46 ? The class in `doctrine/orm` is not the one exposing the `lookahead` property. The class doing that is `Doctrine\Common\Lexer\AbstractLexer`. This probably means `oro/doctrine-extensions` should indeed specify a version constraint for `doctrine/lexer`.
Author
Owner

@alexander-schranz commented on GitHub (Jan 28, 2024):

I did a PR on the oro extensions, https://github.com/oroinc/doctrine-extensions/pull/96. But think I need to also increase the required version for orm and dbal as doctrine/lexer did not exist always on older orm versions.

@alexander-schranz commented on GitHub (Jan 28, 2024): I did a PR on the oro extensions, https://github.com/oroinc/doctrine-extensions/pull/96. But think I need to also increase the required version for orm and dbal as doctrine/lexer did not exist always on older orm versions.
Author
Owner

@alexander-schranz commented on GitHub (Jan 29, 2024):

Same problem found for: https://github.com/martin-georgiev/postgresql-for-doctrine/pull/177 and here alrey PR exists https://github.com/ScientaNL/DoctrineJsonFunctions/pull/95

@alexander-schranz commented on GitHub (Jan 29, 2024): Same problem found for: https://github.com/martin-georgiev/postgresql-for-doctrine/pull/177 and here alrey PR exists https://github.com/ScientaNL/DoctrineJsonFunctions/pull/95
Author
Owner

@greg0ire commented on GitHub (Jan 29, 2024):

To clarify a bit further why we might have not allowed doctrine/lexer 3 before, I think we probably thought best to give a chance to everyone to notice the deprecations, since they are more helpful. In the end, it's still good to allow Lexer 3 on ORM 2, because it allows everyone to do the upgrade to ORM more progressively: they can upgrade to Lexer 3, deploy, and then upgrade to ORM 3 separately. It's a smaller upgrade.

@greg0ire commented on GitHub (Jan 29, 2024): To clarify a bit further why we might have not allowed `doctrine/lexer` 3 before, I think we probably thought best to give a chance to everyone to notice the deprecations, since they are more helpful. In the end, it's still good to allow Lexer 3 on ORM 2, because it allows everyone to do the upgrade to ORM more progressively: they can upgrade to Lexer 3, deploy, and then upgrade to ORM 3 separately. It's a smaller upgrade.
Author
Owner

@alexander-schranz commented on GitHub (Feb 5, 2024):

I think we can close this one as it is not an issue on the doctrine side as the other packages need to define there dependencies here deeper.

@alexander-schranz commented on GitHub (Feb 5, 2024): I think we can close this one as it is not an issue on the doctrine side as the other packages need to define there dependencies here deeper.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7305