Skip to content

Commit c4d6629

Browse files
kerbert101greg0ire
authored andcommitted
fix: return property names in AbstractSqlExecutor::__sleep
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.
1 parent e8afa9f commit c4d6629

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212
use function array_diff;
1313
use function array_keys;
14+
use function array_map;
1415
use function array_values;
16+
use function str_replace;
1517

1618
/**
1719
* Base class for SQL statement executors.
@@ -84,7 +86,9 @@ public function __sleep(): array
8486
serialized representation becomes compatible with 3.0.x, meaning
8587
there will not be a deprecation warning about a missing property
8688
when unserializing data */
87-
return array_values(array_diff(array_keys((array) $this), ["\0*\0_sqlStatements"]));
89+
return array_values(array_diff(array_map(static function (string $prop): string {
90+
return str_replace("\0*\0", '', $prop);
91+
}, array_keys((array) $this)), ['_sqlStatements']));
8892
}
8993

9094
public function __wakeup(): void

0 commit comments

Comments
 (0)