Browse Source

Fixed bug where component behaviors could be double-attached (#16663)

This fixes a 3.0 bug introduced in #16430.

If a component's behaviors() method returns any behaviors without a name, then cloning it would result in the behavior getting attached twice.
3.0
Brandon Kelly 6 years ago committed by Alexander Makarov
parent
commit
1d5ae6de43
  1. 4
      framework/base/Component.php

4
framework/base/Component.php

@ -311,9 +311,9 @@ class Component extends BaseObject
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);
}
}
}

Loading…
Cancel
Save