-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
Lack of infinite recursion detection for abstract factories #218
Comments
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
I would implement somthing like this: laminas-servicemanager/src/ServiceManager.php Lines 967 to 980 in c97780e
if (isset($this->pendingAbstractFactoryChecks[$name])) {
return false;
}
$this->pendingAbstractFactoryChecks[$name] = $name;
foreach ($this->abstractFactories as $abstractFactory) {
if ($abstractFactory->canCreate($this->creationContext, $name)) {
unset($this->pendingAbstractFactoryChecks[$name]);
return true;
}
}
$resolvedName = $this->aliases[$name] ?? $name;
if ($resolvedName !== $name) {
if ($this->abstractFactoryCanCreate($resolvedName)) {
unset($this->pendingAbstractFactoryChecks[$name]);
return true;
}
}
unset($this->pendingAbstractFactoryChecks[$name]);
return false; But I guess that the problem might be that we have to keep track of which abstract factory is currently being checked and just skip that abstract factory which was called lately so that all but the current one is being checked. |
Bug Report
Summary
There is a lack of infinite recursion detection for both
get
andhas
when it comes to abstract factories.Ref: laminas/laminas-cache#284
Current behavior
When checking a service via
has
in factories (one abstract factory has to be involved) or receiving a service viaget
, an infinite recursion along with an application crash is the result.$container->has('foo');
services
,aliases
andfactories
forfoo
foo
not found inservices
,aliases
orfactories
foo
$container->has('foo');
will start over No. 1How to reproduce
Expected behavior
Infinite recursions are prevented from abstract factories.
The text was updated successfully, but these errors were encountered: