Skip to content

Serialize/deserialize loses some data #19701

@cuchac

Description

@cuchac

Description

Serialization and deserialization of slightly complex structure with one object placed inside multiple other objects causes data loss.
I have created a reproducer https://3v4l.org/2m3Jb

It is quite easy to avoid this bug. For example by removing the __sleep function. It took me quite a while to prepare a working reproducer, even slight changes stops triggering the problem.

<?php

assert(is_array($data->second->items[0]->children));

$data = unserialize(serialize($data));

assert(is_array($data->second->items[0]->children));

It could be similar problem to 12265 but 12265 only affects PHP >=8.1. This bug is probably present in even older releases, but I did not make the reproducer to run in such old versions.

PHP Version

All versions >= PHP 7.4, probably even older

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions