Commit 3ea2ffbb by Qiang Xue

Fixed the issue that `ServiceLocator` still returns the old component after…

Fixed the issue that `ServiceLocator` still returns the old component after calling `set()` with a new definition
parent c67c4910
...@@ -26,6 +26,7 @@ Yii Framework 2 Change Log ...@@ -26,6 +26,7 @@ Yii Framework 2 Change Log
- Bug #3327: Fixed "Unable to find debug data" when logging objects with circular references (jarekkozak, samdark) - Bug #3327: Fixed "Unable to find debug data" when logging objects with circular references (jarekkozak, samdark)
- Bug #3368: Fix for comparing numeric attributes in JavaScript (technixp) - Bug #3368: Fix for comparing numeric attributes in JavaScript (technixp)
- Bug: Fixed inconsistent return of `\yii\console\Application::runAction()` (samdark) - Bug: Fixed inconsistent return of `\yii\console\Application::runAction()` (samdark)
- Bug: Fixed the issue that `ServiceLocator` still returns the old component after calling `set()` with a new definition (qiangxue)
- Enh #2264: `CookieCollection::has()` will return false for expired or removed cookies (qiangxue) - Enh #2264: `CookieCollection::has()` will return false for expired or removed cookies (qiangxue)
- Enh #2435: `yii\db\IntegrityException` is now thrown on database integrity errors instead of general `yii\db\Exception` (samdark) - Enh #2435: `yii\db\IntegrityException` is now thrown on database integrity errors instead of general `yii\db\Exception` (samdark)
- Enh #2837: Error page now shows arguments in stack trace method calls (samdark) - Enh #2837: Error page now shows arguments in stack trace method calls (samdark)
......
...@@ -188,6 +188,8 @@ class ServiceLocator extends Component ...@@ -188,6 +188,8 @@ class ServiceLocator extends Component
return; return;
} }
unset($this->_components[$id]);
if (is_object($definition) || is_callable($definition, true)) { if (is_object($definition) || is_callable($definition, true)) {
// an object, a class name, or a PHP callable // an object, a class name, or a PHP callable
$this->_definitions[$id] = $definition; $this->_definitions[$id] = $definition;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment