Closed mesiarm closed 4 months ago
Hi, when opening an issue, it always useful to fill correctly the template.
``` $ composer show --latest 'sonata-project/*' # Put the result here. ```
``` $ composer show --latest 'symfony/*' # Put the result here. ```
Also,
lazyObjectState
is not a property used by Sonata ; did you consider to report the issue on doctrine side instead ?ErrorException:
User Notice: Undefined property: Proxies\__CG__\App\Entity\SonataPageBlock::$lazyObjectState in D:\*****\******\******\sonata\private\vendor\symfony\property-access\PropertyAccessor.php on line 488
at D:\*****\******\******\sonata\private\vendor\symfony\var-exporter\LazyGhostTrait.php:193
at Proxies\__CG__\App\Entity\SonataPageBlock->__get('lazyObjectState')
(D:\*****\******\******\sonata\private\vendor\symfony\property-access\PropertyAccessor.php:488)
at Symfony\Component\PropertyAccess\PropertyAccessor->readProperty(array(object(SonataPageBlock)), 'lazyObjectState', false)
(D:\*****\******\******\sonata\private\vendor\symfony\property-access\PropertyAccessor.php:154)
at Symfony\Component\PropertyAccess\PropertyAccessor->getValue(object(SonataPageBlock), 'lazyObjectState')
(D:\*****\******\******\sonata\private\vendor\symfony\serializer\Normalizer\ObjectNormalizer.php:136)
at Symfony\Component\Serializer\Normalizer\ObjectNormalizer->getAttributeValue(object(SonataPageBlock), 'lazyObjectState', null, array('datetime_format' => 'U', 'skip_null_values' => true, 'callbacks' => array('blocks' => object(Closure), 'parent' => object(Closure)), 'cache_key' => false, 'circular_reference_limit_counters' => array('00000000000005400000000000000000' => 1, '00000000000008a70000000000000000' => 1)))
(D:\*****\******\******\sonata\private\vendor\symfony\serializer\Normalizer\AbstractObjectNormalizer.php:190)
at Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer->normalize(object(SonataPageBlock), null, array('datetime_format' => 'U', 'skip_null_values' => true, 'callbacks' => array('blocks' => object(Closure), 'parent' => object(Closure)), 'cache_key' => false, 'circular_reference_limit_counters' => array('00000000000005400000000000000000' => 1, '00000000000008a70000000000000000' => 1)))
(D:\*****\******\******\sonata\private\vendor\symfony\serializer\Serializer.php:161)
at Symfony\Component\Serializer\Serializer->normalize(object(SonataPageBlock), null, array('datetime_format' => 'U', 'skip_null_values' => true, 'callbacks' => array('blocks' => object(Closure), 'parent' => object(Closure)), 'cache_key' => false, 'circular_reference_limit_counters' => array('00000000000005400000000000000000' => 1)))
(D:\*****\******\******\sonata\private\vendor\symfony\serializer\Serializer.php:179)
at Symfony\Component\Serializer\Serializer->normalize(array(object(SonataPageBlock), object(SonataPageBlock), object(SonataPageBlock), object(SonataPageBlock), object(SonataPageBlock), object(SonataPageBlock), object(SonataPageBlock), object(SonataPageBlock), object(SonataPageBlock), object(SonataPageBlock)), null, array('datetime_format' => 'U', 'skip_null_values' => true, 'callbacks' => array('blocks' => object(Closure), 'parent' => object(Closure)), 'cache_key' => false, 'circular_reference_limit_counters' => array('00000000000005400000000000000000' => 1)))
(D:\*****\******\******\sonata\private\vendor\symfony\serializer\Normalizer\AbstractObjectNormalizer.php:224)
at Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer->normalize(object(SonataPagePage), null, array('datetime_format' => 'U', 'skip_null_values' => true, 'callbacks' => array('blocks' => object(Closure), 'parent' => object(Closure)), 'cache_key' => false, 'circular_reference_limit_counters' => array('00000000000005400000000000000000' => 1)))
(D:\*****\******\******\sonata\private\vendor\symfony\serializer\Serializer.php:161)
at Symfony\Component\Serializer\Serializer->normalize(object(SonataPagePage), null, array('datetime_format' => 'U', 'skip_null_values' => true, 'callbacks' => array('blocks' => object(Closure), 'parent' => object(Closure))))
(D:\*****\******\******\sonata\private\vendor\sonata-project\page-bundle\src\Entity\Transformer.php:100)
at Sonata\PageBundle\Entity\Transformer->create(object(SonataPagePage), object(SonataPageSnapshot))
(D:\*****\******\******\sonata\private\vendor\sonata-project\page-bundle\src\Admin\SnapshotAdmin.php:76)
at Sonata\PageBundle\Admin\SnapshotAdmin->prePersist(object(SonataPageSnapshot))
(D:\*****\******\******\sonata\private\vendor\sonata-project\admin-bundle\src\Admin\AbstractAdmin.php:404)
at Sonata\AdminBundle\Admin\AbstractAdmin->create(object(SonataPageSnapshot))
(D:\*****\******\******\sonata\private\vendor\sonata-project\admin-bundle\src\Controller\CRUDController.php:594)
at Sonata\AdminBundle\Controller\CRUDController->createAction(object(SiteRequest))
(D:\*****\******\******\sonata\private\vendor\symfony\http-kernel\HttpKernel.php:163)
at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(SiteRequest), 1)
(D:\*****\******\******\sonata\private\vendor\symfony\http-kernel\HttpKernel.php:75)
at Symfony\Component\HttpKernel\HttpKernel->handle(object(SiteRequest), 1, true)
(D:\*****\******\******\sonata\private\vendor\symfony\http-kernel\Kernel.php:202)
at Symfony\Component\HttpKernel\Kernel->handle(object(SiteRequest))
(D:\*****\******\******\sonata\web\index.php:26)
SonataPageBlock was only Entity, where I got this error.
Thanks, it's more an issue with SonataPage then, and the way the serializer works.
Certainly related to https://github.com/sonata-project/SonataPageBundle/pull/1522 cc @Hanmac
ugh i need to debug this more
i don't know what the best way with lazy doctrine + serializer would be
i will post when i find out more
@VincentLanglet i can't test it right now (i don't have Sonata Page Project at the moment)
but can you check what happens when you add the ugly Doctrine Property to the list of ignored ones? https://github.com/sonata-project/SonataPageBundle/blob/4.x/src/Resources/config/serialization/Model.Block.xml
@VincentLanglet can you (or someone else) help me to create an extra UnitTest Case with lazy doctrine enabled so i can test this better?
(i don't have Sonata Page Project at the moment)
I never used it , but maybe @mesiarm can help you about a reproducer
@VincentLanglet can you (or someone else) help me to create an extra UnitTest Case with lazy doctrine enabled so i can test this better?
I never did it before
@mesiarm can you post part of your doctrine and/or serializer config so i can try to reproduce your error in a test case?
This is my doctrine.yaml config. I dont have serializer config
I'm using latest Sonata bundles and Symfony 6.4. I have page that has only one Simple Text Block from Block bundle and when I'm creating a snapshot for that page. I get User Notice: Undefined property: Proxies\__CG__\App\Entity\SonataPageBlock::$lazyObjectState in symfony/vendor/symfony/property-access/PropertyAccessor.php on line 418
Setting enable_lazy_ghost_objects: false
fixes this error.
@haivala yeah i 'm trying to make a reproducable test case, but i couldn't got the Unit tests to throw that Error
I think one way would be to Force the Collection to be loaded, but for this i need the unit tests to check
I'm just wondering: Is this only thing that needs a fix for us to be able to allow Symfony 7?
@haivala i haven't time yet to make it reproducible probably because the testcases uses different orm
can you test it what happens if you make the Page Collection loaded before this point? https://github.com/sonata-project/SonataPageBundle/blob/4.x/src/Entity/Transformer.php#L100
something like:
$page->getChildren()->getValues()
$page->getBlocks()->getValues()
before ?
(i might need to check how to load all the Children, and all the block children?)
I'm just wondering: Is this only thing that needs a fix for us to be able to allow Symfony 7?
Noticed that this is missing ORM 3 support
@Hanmac Now I get error Ignore on "Proxies\__CG__\App\Entity\Sonata\SonataPageBlock::__setInitialized()" cannot be added. Ignore can only be added on methods beginning with "get", "is", "has" or "set".
@Hanmac Now I get error
Ignore on "Proxies\__CG__\App\Entity\Sonata\SonataPageBlock::__setInitialized()" cannot be added. Ignore can only be added on methods beginning with "get", "is", "has" or "set".
that looks like a new Bug in Symfony Serializer again, __setInitialized doesn't exist in the Sonata Code
Please Open the Issue on the Symfony Repo
Edit: there is alreaddy one: https://github.com/symfony/symfony/issues/54477
The issue https://github.com/symfony/symfony/issues/54477 is solved ; does it solve your issue ?
The issue symfony/symfony#54477 is solved ; does it solve your issue ?
I guess need to wait for Symfony 5.4.39 and 6.4.7 https://github.com/symfony/symfony/pull/54485#issuecomment-2079266369
I tested and it seems to work with the new serializer
The issue symfony/symfony#54477 is solved ; does it solve your issue ?
I guess need to wait for Symfony 5.4.39 and 6.4.7 symfony/symfony#54485 (comment)
it was released.
When I set enable_lazy_ghost_objects to true in doctrine.yaml (not setting true is deprecated) I got error after I updated sonata Block and wanted to create new Snapshot of page: User Notice: Undefined property: Proxies__CG__\App\Entity\SonataPageBlock::$lazyObjectState in ....\sonata\private\vendor\symfony\property-access\PropertyAccessor.php on line 488