Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Symfony/Component/VarExporter/Internal/Exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ public static function prepare($values, $objectsPool, &$refsPool, &$objectsCount
}
if (null !== $sleep) {
if (!isset($sleep[$n]) || ($i && $c !== $class)) {
unset($arrayValue[$name]);
continue;
}
$sleep[$n] = false;
Expand All @@ -164,6 +165,9 @@ public static function prepare($values, $objectsPool, &$refsPool, &$objectsCount
}
}
}
if (method_exists($class, '__unserialize')) {
$properties = $arrayValue;
}

prepare_value:
$objectsPool[$value] = [$id = \count($objectsPool)];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

return \Symfony\Component\VarExporter\Internal\Hydrator::hydrate(
$o = [
clone (\Symfony\Component\VarExporter\Internal\Registry::$prototypes['Symfony\\Component\\VarExporter\\Tests\\__UnserializeButNo__Serialize'] ?? \Symfony\Component\VarExporter\Internal\Registry::p('Symfony\\Component\\VarExporter\\Tests\\__UnserializeButNo__Serialize')),
],
null,
[],
$o[0],
[
[
'foo' => 'ccc',
],
]
);
17 changes: 17 additions & 0 deletions src/Symfony/Component/VarExporter/Tests/VarExporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ public function provideExport()

yield ['php74-serializable', new Php74Serializable()];

yield ['__unserialize-but-no-__serialize', new __UnserializeButNo__Serialize()];

if (\PHP_VERSION_ID < 80100) {
return;
}
Expand Down Expand Up @@ -453,3 +455,18 @@ public function unserialize($ser)
class ArrayObject extends \ArrayObject
{
}

class __UnserializeButNo__Serialize
{
public $foo;

public function __construct()
{
$this->foo = 'ccc';
}

public function __unserialize(array $data): void
{
$this->foo = $data['foo'];
}
}