Skip to content

Commit

Permalink
Fixed bug where component behaviors could be double-attached
Browse files Browse the repository at this point in the history
This fixes a 3.0 bug introduced in yiisoft/yii2#16430.

If a component's behaviors() method returns any behaviors without a name, then cloning it would result in the behavior getting attached twice.
  • Loading branch information
brandonkelly committed Aug 28, 2018
1 parent 7a57d70 commit 71440e7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/base/Component.php
Expand Up @@ -314,9 +314,9 @@ public function __clone()

if ($this->_behaviors !== null) {
$behaviors = $this->_behaviors;
$this->_behaviors = null;
$this->_behaviors = [];
foreach ($behaviors as $name => $behavior) {
$this->attachBehavior($name, clone $behavior);
$this->attachBehaviorInternal($name, clone $behavior);
}
}
}
Expand Down

0 comments on commit 71440e7

Please sign in to comment.