oroinc / platform

Main OroPlatform package with core functionality.
Other
628 stars 351 forks source link

PHP Warning: Invalid argument supplied for foreach() #677

Open vodvud opened 7 years ago

vodvud commented 7 years ago

Hi!

Sometimes I see a warning: PHP Warning: Invalid argument supplied for foreach() in /var/www/orocrm/vendor/oro/platform/src/Oro/Bundle/FormBundle/Form/EventListener/CollectionTypeSubscriber.php on line 115

https://github.com/orocrm/platform/blob/master/src/Oro/Bundle/FormBundle/Form/EventListener/CollectionTypeSubscriber.php#L115

There is no "is_array" check in your code.

manowark commented 7 years ago

Hi @vodvud.

Could you please provide me steps to reproduce the issue?

(Internal ticket BAP-14502)

vodvud commented 7 years ago

For example:

PeopleBundle/Form/Type/PersonType.php

        // websites
        $builder->add('website', 'oro_collection', [
            'required' => false,
            'label' => 'people.person.websites.label',
            'entry_type' => CoreType\TextType::class,
            'allow_add' => true,
            'allow_delete' => true,
            'delete_empty' => true,
            'prototype_name' => 'websites',
            'show_form_when_empty' => false,
        ]);

If I add 3 fields to this collection, but filled only one website collection after submit I'll see 2 warning in error log

manowark commented 7 years ago

Thank you.