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
First off I wasn't sure whether to report this here or for the Doctrine Bundle, but as the error is triggered in Symfony code and I did read that @nicolas-grekas did some "lazy ghost voodoo" for the Doctrine Bundle I guess this is a better place to report it :)
Secondly I'm not sure what the fault is yet, nor how to properly reproduce. But what I do know is that doctrine.orm.enable_lazy_ghost_objects being enabled leads to a very strange error with the web profiler. And as I discovered this on the RC version it might be an issue with the RC? Which thus might be something which you'd want to fix before releasing the stable (although I guess it's a bit late / short before the release for that)
In certain scenario's (/on certain pages) the page will end with the following error:
Cannot assign Symfony\Component\VarDumper\Caster\CutStub to reference held by property SomeEntity::$someProperty of type SomeType
This is triggered by the $a[$k] = new CutStub($v); in the DataCollector. In this case $k would resemble a type hinted property (fails both with enum types as object types, at first I thought it might have been enum only) of some class (so in the example it is SomeEntitysomeProperty, for which I'm guessing the FQCN and property are separated by a NULL byte) to which it obviously is trying to assign a new CutStub which doesn't satisfy some "dubiously" inherited type constraint. But I do have absolutely no idea what is triggering this error. This as $a is an array, so it can't actually be typehinted (I've never heart of typehinted array keys/values before 😅), so it seemingly has to do with the "reference held by property"? But I haven't figured out how $a is created yet, so I also don't know whether it involves some &$obj->prop based assignment.
What I do know is that, at least for me, this error is triggered by a Security->isGranted() call where this (Doctrine) entity is used as $subject, and the entity is a (loaded / initialized) proxy (i.e.: a proxy instance has been created due to some other entity actually being loaded which references this entity, after which at some point I have this (now loaded) proxy instance and pass it to isGranted). Which I "discovered" based on the stacktrace (which shows it's eventually called by Symfony\Bundle\SecurityBundle\DataCollector\SecurityDataCollector::lateCollect()) and intensively trying to debug and understand what was going on in the VarDumper code showing one of my attribute names before failing giving the "hint" to disable the isGranted call, and then it works).
How to reproduce
As described above I haven't (tried to) set up a proper reproducer yet. But after writing everything down I do believe it might be as simple as:
Making sure the (new) doctrine.orm.enable_lazy_ghost_objects setting is enabled (for which not enabling it will be deprecated)
Having the WebProfiler enabled
Having a Doctrine entity with object (/ enum) typed properties
Getting a proxy to this entity (i.e.: creating the proxy by loading an entity referencing it, or possibly by calling getReference())
Possibly making sure the proxy is loaded / initialized? (it is in my case, not sure if it also fails when it isn't initialized yet)
calling ->isGranted() with this entity as subject (in my case it's called on the Security helper class/service, but I guess using the AccessManager directly would result in the same error)
Possible Solution
No response
Additional Context
Symfony: ^6.4 RC (so RC2 / RC1 depending on which packages have an RC2)
DoctrineBundle: 2.11.1
PHP: 8.1.2
The text was updated successfully, but these errors were encountered:
Note that I literally found it by putting Cannot assign Symfony\Component\VarDumper\Caster\CutStub to reference held by property in the issue search box.
I did as well, but in the issue search / filter box, and apparently didn't notice the "1 Closed". So lesson learned, use the "global" search :)
Anyway, sorry for the report. Luckily it was easily "solved" on your end and it only costed me some time to write the report, instead of you having invested a lot of time to then still find out it's a ("solved") duplicate.
Symfony version(s) affected
6.4-RC2
Description
First off I wasn't sure whether to report this here or for the Doctrine Bundle, but as the error is triggered in Symfony code and I did read that @nicolas-grekas did some "lazy ghost voodoo" for the Doctrine Bundle I guess this is a better place to report it :)
Secondly I'm not sure what the fault is yet, nor how to properly reproduce. But what I do know is that
doctrine.orm.enable_lazy_ghost_objects
being enabled leads to a very strange error with the web profiler. And as I discovered this on the RC version it might be an issue with the RC? Which thus might be something which you'd want to fix before releasing the stable (although I guess it's a bit late / short before the release for that)In certain scenario's (/on certain pages) the page will end with the following error:
This is triggered by the
$a[$k] = new CutStub($v);
in the DataCollector. In this case$k
would resemble a type hinted property (fails both with enum types as object types, at first I thought it might have been enum only) of some class (so in the example it isSomeEntitysomeProperty
, for which I'm guessing the FQCN and property are separated by a NULL byte) to which it obviously is trying to assign anew CutStub
which doesn't satisfy some "dubiously" inherited type constraint. But I do have absolutely no idea what is triggering this error. This as$a
is an array, so it can't actually be typehinted (I've never heart of typehinted array keys/values before 😅), so it seemingly has to do with the "reference held by property"? But I haven't figured out how$a
is created yet, so I also don't know whether it involves some&$obj->prop
based assignment.What I do know is that, at least for me, this error is triggered by a
Security->isGranted()
call where this (Doctrine) entity is used as$subject
, and the entity is a (loaded / initialized) proxy (i.e.: a proxy instance has been created due to some other entity actually being loaded which references this entity, after which at some point I have this (now loaded) proxy instance and pass it toisGranted
). Which I "discovered" based on the stacktrace (which shows it's eventually called bySymfony\Bundle\SecurityBundle\DataCollector\SecurityDataCollector::lateCollect()
) and intensively trying to debug and understand what was going on in the VarDumper code showing one of my attribute names before failing giving the "hint" to disable theisGranted
call, and then it works).How to reproduce
As described above I haven't (tried to) set up a proper reproducer yet. But after writing everything down I do believe it might be as simple as:
doctrine.orm.enable_lazy_ghost_objects
setting is enabled (for which not enabling it will be deprecated)getReference()
)->isGranted()
with this entity as subject (in my case it's called on theSecurity
helper class/service, but I guess using the AccessManager directly would result in the same error)Possible Solution
No response
Additional Context
Symfony: ^6.4 RC (so RC2 / RC1 depending on which packages have an RC2)
DoctrineBundle: 2.11.1
PHP: 8.1.2
The text was updated successfully, but these errors were encountered: