Skip to content

Clone on lazy ghost does loose data #2851

@Nilz11

Description

@Nilz11

Bug Report

Q A
BC Break yes/no
Version 2.13

Summary

Issue seems to be the same as in doctrine/orm:

doctrine/orm#11787

If you call clone on an unitialized proxy loaded via @ReferenceOne, it does not initialize properly and data is gone.

Current behavior

$child = $parent->getChild(); // Proxy of $child. Empty. 
$clonedParent = clone $child;

$clonedParent->getName(); // Name if empty, even though it was set in database

How to reproduce

Workaround is to force load the document by accessing property:

$parent->getChild(); // Proxy of $child. Empty. 
$parent->getChild()->getName(); // Force orm to load Proxy.
$parent->getChild(); // Now a fully loaded Proxy;

$clonedParent = clone $parent;
$clonedParent->getChild(); // Proxy of $child. Fully loaded.

Expected behavior

I would expect the proxy to load / initialize properly on calling clone or throw an error.

I couldnt find a usable workaround except forcing it by accessing a different property first. I dont understand the logic here deep enough.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions