Skip to content

Commit

Permalink
[DoctrineBridge] Added type check to prevent calling clear() on arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
webmozart committed Oct 18, 2013
1 parent 1b97ad4 commit 4ff59d7
Showing 1 changed file with 2 additions and 1 deletion.
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Bridge\Doctrine\Form\EventListener;

use Doctrine\Common\Collections\Collection;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
Expand Down Expand Up @@ -40,7 +41,7 @@ public function onBind(FormEvent $event)

// If all items were removed, call clear which has a higher
// performance on persistent collections
if ($collection && count($data) === 0) {
if ($collection instanceof Collection && count($data) === 0) {
$collection->clear();
}
}
Expand Down

0 comments on commit 4ff59d7

Please sign in to comment.