Pārlūkot izejas kodu

[Form] Form::isPostMaxSizeReached() only triggers for root forms

Bernhard Schussek 14 gadi atpakaļ
vecāks
revīzija
7680657944

+ 20 - 0
src/Symfony/Component/Form/Field.php

@@ -241,6 +241,16 @@ class Field extends Configurable implements FieldInterface
         return $this->parent;
     }
 
+    /**
+     * Returns whether the field has a parent.
+     *
+     * @return Boolean
+     */
+    public function hasParent()
+    {
+        return null !== $this->parent;
+    }
+
     /**
      * Returns the root of the form tree
      *
@@ -251,6 +261,16 @@ class Field extends Configurable implements FieldInterface
         return $this->parent ? $this->parent->getRoot() : $this;
     }
 
+    /**
+     * Returns whether the field is the root of the form tree
+     *
+     * @return Boolean
+     */
+    public function isRoot()
+    {
+        return !$this->hasParent();
+    }
+
     /**
      * Updates the field with default data
      *

+ 1 - 1
src/Symfony/Component/Form/Form.php

@@ -235,7 +235,7 @@ class Form extends FieldGroup
      */
     public function isPostMaxSizeReached()
     {
-        if (isset($_SERVER['CONTENT_LENGTH'])) {
+        if ($this->isRoot() && isset($_SERVER['CONTENT_LENGTH'])) {
             $length = (int) $_SERVER['CONTENT_LENGTH'];
             $max = trim(ini_get('post_max_size'));