-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
AbstractSqlExecutor::__sleep should return property names #11065
Conversation
2d521fb
to
c4d6629
Compare
c4d6629
to
12051ce
Compare
I added a test, and now it seems the test breaks for The failure says:
The exporter produces this: \Symfony\Component\VarExporter\Internal\Hydrator::hydrate(
$o = [
clone (($p = &\Symfony\Component\VarExporter\Internal\Registry::$prototypes)['Doctrine\\ORM\\Query\\ParserResult'] ?? \Symfony\Component\VarExporter\Internal\Registry::p('Doctrine\\ORM\\Query\\ParserResult')),
clone ($p['Doctrine\\ORM\\Query\\Exec\\SingleSelectExecutor'] ?? \Symfony\Component\VarExporter\Internal\Registry::p('Doctrine\\ORM\\Query\\Exec\\SingleSelectExecutor')),
clone ($p['Doctrine\\ORM\\Query\\ResultSetMapping'] ?? \Symfony\Component\VarExporter\Internal\Registry::p('Doctrine\\ORM\\Query\\ResultSetMapping')),
],
null,
[
'Doctrine\\ORM\\Query\\Exec\\AbstractSqlExecutor' => [
'sqlStatements' => [
1 => 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, c2_.title AS title_5, c0_.discr AS discr_6, c0_.spouse_id AS spouse_id_7, c2_.car_id AS car_id_8 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id LEFT JOIN company_managers c2_ ON c1_.id = c2_.id WHERE c0_.name = ?',
],
],
'stdClass' => [
'aliasMap' => [
2 => [
'u' => 'Doctrine\\Tests\\Models\\Company\\CompanyEmployee',
],
],
'fieldMappings' => [
2 => [
'id_0' => 'id',
'name_1' => 'name',
'salary_2' => 'salary',
'department_3' => 'department',
'startDate_4' => 'startDate',
'title_5' => 'title',
],
],
'typeMappings' => [
2 => [
'discr_6' => 'string',
'spouse_id_7' => 'integer',
'car_id_8' => 'integer',
],
],
'entityMappings' => [
2 => [
'u' => null,
],
],
'metaMappings' => [
2 => [
'discr_6' => 'discr',
'spouse_id_7' => 'spouse_id',
'car_id_8' => 'car_id',
],
],
'columnOwnerMap' => [
2 => [
'id_0' => 'u',
'name_1' => 'u',
'salary_2' => 'u',
'department_3' => 'u',
'startDate_4' => 'u',
'title_5' => 'u',
'discr_6' => 'u',
'spouse_id_7' => 'u',
'car_id_8' => 'u',
],
],
'discriminatorColumns' => [
2 => [
'u' => 'discr_6',
],
],
'declaringClasses' => [
2 => [
'id_0' => 'Doctrine\\Tests\\Models\\Company\\CompanyEmployee',
'name_1' => 'Doctrine\\Tests\\Models\\Company\\CompanyEmployee',
'salary_2' => 'Doctrine\\Tests\\Models\\Company\\CompanyEmployee',
'department_3' => 'Doctrine\\Tests\\Models\\Company\\CompanyEmployee',
'startDate_4' => 'Doctrine\\Tests\\Models\\Company\\CompanyEmployee',
'title_5' => 'Doctrine\\Tests\\Models\\Company\\CompanyManager',
],
],
],
],
$o[0],
[
[
'Doctrine\\ORM\\Query\\ParserResult' => [
'sqlExecutor' => $o[1],
'resultSetMapping' => $o[2],
'parameterMappings' => [
'name' => [
0,
],
],
],
],
1,
]
) I suspect this issue is orthogonal with the one we are dealing with here. |
Property names as returned by a cast to array are mangled, and that mangling is not documented. Returning unprefixed produces the same result, and is more likely to be supported by external tools relying on the documented possible return values of __sleep. For instance symfony/var-exporter does not support mangled names, which leads to issues when caching query parsing results in Symfony applications.
Would that work for |
12051ce
to
6be65eb
Compare
No, that would not work. Nvm 🙂 |
@nicolas-grekas I'd like your input on this Symfony 4.4 issue… I think this means serialization just does not work right now on Symfony 4 apps? It seems weird. Anyway, Symfony 4.4. is EOL so… not worth fixing IMO. Maybe we should drop it from our |
I don't care about 4.4 anymore :) |
So what does this mean for this PR? |
2 things:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've read the issue and the Symfony PR. I hope people can now sleep better without the prefixes. I will. Thanks to everyone who got involved in this fix.
If not compatible with Symfony 4.4, can't we add it in composer.json conflict? |
I don't know for sure that it isn't. I mean, this is just a test, maybe there's something that makes the conflict not meaningful, like maybe PhpFilesCache isn't available on Symfony 4.4. Are you by any chance using Symfony 4.4? |
(Un)fortunately, no |
Ok, cause I would be surprised that something this big and unrelated to what I did recently in 2.17 would have gone unnoticed for so long. |
@kerbert101 congrats on your first contribution BTW 🎉 |
From php.net:
serialize
supports the prepended property names, but this is undocumented.VarExporter
does not support prepended property names. ThePhpFilesAdapter
usesVarExporter
to create a php cache file. To prevent issues, we need to return the property names without the prefixes added by php when casting an object to an array.Fixes #11063