-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[VarExporter] Cannot access property starting with "\0" #54905
Comments
Can you create a small example application that allows to reproduce your issue? |
Does this still happen with 7.0.7? We've fixed some issues in that area lately. |
Yes, it does. I upgrade symfony to 7.0.7 and i still stable repeat this error. I can't share source code, and i can't reporudce this on fresh symfony install, but in my project it stable error. Under stable i mean that case: |
Without being able to reproduce I am afraid that you will have to debug the root cause yourself. |
I think it's var-exporter bug because in source code hydrates starts from this and because in 6.x.x symfony version i never seen it before with large of coding in sf 6 Hydrator::hydrate($object, ["\0Bar\0privateBarProperty" => $propertyValue]); Where "\0" is special property and it doesn't exists for proxy object of doctrine entity where it not correctly reseted (may be it depends on dump/cache component) And of course i think it's all same errors like this #54477 |
This code is special handling for SplObjectStorage instances, I doubt it's the culprit. Can you please create a small app or script that'd allow us to reproduce? |
I will try but not now. Sorry. |
I can give more info if i dumped public static function hydrate(object $instance, array $properties = [], array $scopedProperties = []): object
{
if ($properties) {
$class = $instance::class;
$propertyScopes = InternalHydrator::$propertyScopes[$class] ??= InternalHydrator::getPropertyScopes($class);
foreach ($properties as $name => &$value) {
[$scope, $name, $readonlyScope] = $propertyScopes[$name] ?? [$class, $name, $class];
$scopedProperties[$readonlyScope ?? $scope][$name] = &$value;
}
unset($value);
}
// DUMP HERE
var_dump($scopedProperties);
foreach ($scopedProperties as $scope => $properties) {
if ($properties) {
(InternalHydrator::$simpleHydrators[$scope] ??= InternalHydrator::getSimpleHydrator($scope))($properties, $instance);
}
}
return $instance;
} I see 2 instances of my entity
Last entity Then if i changed public static function hydrate(object $instance, array $properties = [], array $scopedProperties = []): object
{
if ($properties) {
$class = $instance::class;
$propertyScopes = InternalHydrator::$propertyScopes[$class] ??= InternalHydrator::getPropertyScopes($class);
foreach ($properties as $name => &$value) {
[$scope, $name, $readonlyScope] = $propertyScopes[$name] ?? [$class, $name, $class];
$scopedProperties[$readonlyScope ?? $scope][$name] = &$value;
}
unset($value);
}
unset($scopedProperties['Proxies\__CG__\App\Entity\Organization']);
foreach ($scopedProperties as $scope => $properties) {
if ($properties) {
(InternalHydrator::$simpleHydrators[$scope] ??= InternalHydrator::getSimpleHydrator($scope))($properties, $instance);
}
}
return $instance;
} then all fine, because $scopedProperties entity is correct. Hope this helps. |
Symfony version(s) affected
7.0.6
Description
I have entity
App\Entity\Organization
and form with
data_class
=App\Entity\Organization
and route like this
When i change fields in entity ( for example add new field ), add migration, migrate. Then if i don't reset cache manually or do not restart my php-fpm server, i get error
Cannot access property starting with "\0"
If i change code without
ParamConverter
all works fine. I getnot proxied
entity and var exporter works fineHow to reproduce
Create route with annotation with
#[Route('/{id}/edit', name: 'my_route', methods: ['GET', 'POST'])]
withid
param to convert param to entity and make entity for this withtitle
property. Then create form withdata_class
inconfigureOptions
PHP version is:
PHP 8.2.18 (cli) (built: Apr 11 2024 19:20:54) (NTS)
Database is
postgresql
Setttings for
doctrine.yaml
Possible Solution
Custom ParamConverter or use manually finding entity by params
This works fine.
Additional Context
The text was updated successfully, but these errors were encountered: