Fixed self-reference in 'service_container' service breaks garbage collection (and clone).
This commit is contained in:
parent
497c875304
commit
440322effc
@ -93,8 +93,6 @@ class Container implements IntrospectableContainerInterface
|
||||
$this->scopeChildren = array();
|
||||
$this->scopedServices = array();
|
||||
$this->scopeStacks = array();
|
||||
|
||||
$this->set('service_container', $this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -204,6 +202,12 @@ class Container implements IntrospectableContainerInterface
|
||||
|
||||
$id = strtolower($id);
|
||||
|
||||
if ('service_container' === $id) {
|
||||
// BC: 'service_container' is no longer a self-reference but always
|
||||
// $this, so ignore this call.
|
||||
// @todo Throw InvalidArgumentException in next major release.
|
||||
return;
|
||||
}
|
||||
if (self::SCOPE_CONTAINER !== $scope) {
|
||||
if (!isset($this->scopedServices[$scope])) {
|
||||
throw new RuntimeException(sprintf('You cannot set service "%s" of inactive scope.', $id));
|
||||
@ -240,6 +244,10 @@ class Container implements IntrospectableContainerInterface
|
||||
{
|
||||
$id = strtolower($id);
|
||||
|
||||
if ('service_container' === $id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return isset($this->services[$id])
|
||||
|| array_key_exists($id, $this->services)
|
||||
|| isset($this->aliases[$id])
|
||||
@ -276,6 +284,9 @@ class Container implements IntrospectableContainerInterface
|
||||
if ($strtolower) {
|
||||
$id = strtolower($id);
|
||||
}
|
||||
if ('service_container' === $id) {
|
||||
return $this;
|
||||
}
|
||||
if (isset($this->aliases[$id])) {
|
||||
$id = $this->aliases[$id];
|
||||
}
|
||||
@ -347,6 +358,12 @@ class Container implements IntrospectableContainerInterface
|
||||
{
|
||||
$id = strtolower($id);
|
||||
|
||||
if ('service_container' === $id) {
|
||||
// BC: 'service_container' was a synthetic service previously.
|
||||
// @todo Change to false in next major release.
|
||||
return true;
|
||||
}
|
||||
|
||||
return isset($this->services[$id]) || array_key_exists($id, $this->services);
|
||||
}
|
||||
|
||||
@ -364,6 +381,7 @@ class Container implements IntrospectableContainerInterface
|
||||
$ids[] = self::underscore($match[1]);
|
||||
}
|
||||
}
|
||||
$ids[] = 'service_container';
|
||||
|
||||
return array_unique(array_merge($ids, array_keys($this->services)));
|
||||
}
|
||||
|
Reference in New Issue
Block a user