ソースを参照

Fix infinite loop on circullar reference in form factory

When `->getName()` returns the same as `getParent()` we're going to infinite loop.
Dariusz Górecki 13 年 前
コミット
36cebf0924
1 ファイル変更4 行追加0 行削除
  1. 4 0
      src/Symfony/Component/Form/FormFactory.php

+ 4 - 0
src/Symfony/Component/Form/FormFactory.php

@@ -220,6 +220,10 @@ class FormFactory implements FormFactoryInterface
 
         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);