Skip to content

Commit

Permalink
merged branch canni/throw_exception_on_form_name_circulal_ref (PR sym…
Browse files Browse the repository at this point in the history
…fony#2675)

Commits
-------

36cebf0 Fix infinite loop on circullar reference in form factory

Discussion
----------

[BugFix][Form]Throw exception on form name circulal ref

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Closes: symfony#2673

When FormType method `getName()` returns the same value as `getParent()` we're asking about trouble, and land into infinite loop.
  • Loading branch information
fabpot committed Nov 22, 2011
2 parents 7c8d836 + 36cebf0 commit af27132
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Symfony/Component/Form/FormFactory.php
Expand Up @@ -220,6 +220,10 @@ public function createNamedBuilder($type, $name, $data = null, array $options =

while (null !== $type) {
if ($type instanceof FormTypeInterface) {
if ($type->getName() == $type->getParent($options)) {
throw new FormException(sprintf('The "%s" form type name ("%s") is not valid. It contains circullar reference to parent type name ("%s")', get_class($type), $type->getName(), $type->getParent($options)));
}

$this->addType($type);
} else {
$type = $this->getType($type);
Expand Down

0 comments on commit af27132

Please sign in to comment.