bug #10215 [Routing] reduced recursion in dumper (arnaud-lb)
This PR was submitted for the 2.3-dev branch but it was merged into the 2.3 branch instead (closes #10215). Discussion ---------- [Routing] reduced recursion in dumper | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | sensiolabs/SensioFrameworkExtraBundle/issues/275 | License | MIT This reduces recursion in the route dumper, avoiding issues with xdebug's recursion limit. Commits ------- fa6eebc reduced recursion when building DumperPrefixCollection 9278b27 renamed variables - making next change more readable
This commit is contained in:
commit
f964cc8474
|
@ -56,29 +56,27 @@ class DumperPrefixCollection extends DumperCollection
|
|||
{
|
||||
$prefix = $route->getRoute()->compile()->getStaticPrefix();
|
||||
|
||||
// Same prefix, add to current leave
|
||||
if ($this->prefix === $prefix) {
|
||||
$this->add($route);
|
||||
for ($collection = $this; null !== $collection; $collection = $collection->getParent()) {
|
||||
|
||||
return $this;
|
||||
// Same prefix, add to current leave
|
||||
if ($collection->prefix === $prefix) {
|
||||
$collection->add($route);
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
// Prefix starts with route's prefix
|
||||
if ('' === $collection->prefix || 0 === strpos($prefix, $collection->prefix)) {
|
||||
$child = new DumperPrefixCollection();
|
||||
$child->setPrefix(substr($prefix, 0, strlen($collection->prefix)+1));
|
||||
$collection->add($child);
|
||||
|
||||
return $child->addPrefixRoute($route);
|
||||
}
|
||||
}
|
||||
|
||||
// Prefix starts with route's prefix
|
||||
if ('' === $this->prefix || 0 === strpos($prefix, $this->prefix)) {
|
||||
$collection = new DumperPrefixCollection();
|
||||
$collection->setPrefix(substr($prefix, 0, strlen($this->prefix)+1));
|
||||
$this->add($collection);
|
||||
|
||||
return $collection->addPrefixRoute($route);
|
||||
}
|
||||
|
||||
// No match, fallback to parent (recursively)
|
||||
|
||||
if (null === $parent = $this->getParent()) {
|
||||
throw new \LogicException("The collection root must not have a prefix");
|
||||
}
|
||||
|
||||
return $parent->addPrefixRoute($route);
|
||||
// Reached only if the root has a non empty prefix
|
||||
throw new \LogicException("The collection root must not have a prefix");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Reference in New Issue