Skip to content
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

Strange behavior while adding __clone function in User class #2609

Open
lilworks opened this issue Sep 27, 2017 · 2 comments
Open

Strange behavior while adding __clone function in User class #2609

lilworks opened this issue Sep 27, 2017 · 2 comments

Comments

@lilworks
Copy link

lilworks commented Sep 27, 2017

Is it possible to use the __clone function inside de User class? Each time I implement this class I get really strange beahavior... The app always return to the login check route!

@jbarton123
Copy link

jbarton123 commented Oct 5, 2017

I've also just encountered this. Very strange. If anyone has an answer as to why this is, it'd be good to know!

I only needed to nullify a couple of properties in my entity on clone so I've been able to do this in the controller after cloning the entity object but admittedly it would be nicer to have these in __clone()

$obj = new Obj();
$obj2 = clone $obj;
$obj2->setId(null);

@jbarton123
Copy link

In fact, I've just found this;
http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/architecture.html#entities

This seems to suggest that using __clone() in entities is really a no no unless you safely implement the method. However, even using the example there and only running when the check for an ID passes seems to log me back out...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants