-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Cloning objects should also clone their behaviors #16247
Labels
Milestone
Comments
Yes. It's not backwards compatible and could be done in 2.1. Would you like to send a pull request? |
I figured it would be more of a 2.1 thing. Happy to submit a PR. |
brandonkelly
added a commit
to craftcms/cms
that referenced
this issue
Jun 22, 2018
Rushed fix for yiisoft/yii2#16247 Fixes #2857 Better fix for #3019
brandonkelly
added a commit
to brandonkelly/yii2
that referenced
this issue
Jun 22, 2018
brandonkelly
added a commit
to brandonkelly/yii2
that referenced
this issue
Jun 22, 2018
samdark
pushed a commit
that referenced
this issue
Jun 22, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently, Component::__clone() will null-out the
$_behaviors
array:yii2/framework/base/Component.php
Lines 307 to 312 in 3d96a45
I can see why this is better than leaving
$_behaviors
alone (those behaviors contain a reference to the original component instance), but I think it would be better if those behaviors were cloned to the new instance as well.That way any property values set on the behavior will be maintained on the cloned instance, just like normal properties.
(related: craftcms/cms#2857)
The text was updated successfully, but these errors were encountered: