فهرست منبع

[Form] added a missing check (the code calls isset() and unset() and so the data must implements ArrayAccess and Traversable)

Fabien Potencier 14 سال پیش
والد
کامیت
b2efdcbad9
1فایلهای تغییر یافته به همراه6 افزوده شده و 6 حذف شده
  1. 6 6
      src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php

+ 6 - 6
src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php

@@ -79,8 +79,8 @@ class ResizeFormListener implements EventSubscriberInterface
             $data = array();
         }
 
-        if (!is_array($data) && !$data instanceof \Traversable) {
-            throw new UnexpectedTypeException($data, 'array or \Traversable');
+        if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) {
+            throw new UnexpectedTypeException($data, 'array or \Traversable or \ArrayAccess');
         }
 
         // First remove all rows
@@ -105,8 +105,8 @@ class ResizeFormListener implements EventSubscriberInterface
             $data = array();
         }
 
-        if (!is_array($data) && !$data instanceof \Traversable) {
-            throw new UnexpectedTypeException($data, 'array or \Traversable');
+        if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) {
+            throw new UnexpectedTypeException($data, 'array or \Traversable or \ArrayAccess');
         }
 
         // Remove all empty rows
@@ -139,8 +139,8 @@ class ResizeFormListener implements EventSubscriberInterface
             $data = array();
         }
 
-        if (!is_array($data) && !$data instanceof \Traversable) {
-            throw new UnexpectedTypeException($data, 'array or \Traversable');
+        if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) {
+            throw new UnexpectedTypeException($data, 'array or \Traversable or \ArrayAccess');
         }
 
         if ($this->allowDelete) {