Search code examples
phpsymfonydebuggingsymfony-2.6

Symfony 2.6 "PropertyAccessor" exception: Expected argument of type "object or array", "NULL" given


Symfony is giving me an error on a CRUD page in my admin back-end:

Symfony 2.6 exception: Expected argument of type "object or array", "NULL" given

Full stack trace is below,

line 132 of the pertinent source file is here:

https://github.com/symfony/PropertyAccess/blob/master/PropertyAccessor.php

Has anyone had experience with this type of exception before? Where the hell should I be looking, for a non-existent twig value? In the FormType object? The Entity? The configuration .yml settings?

I've tried git bisecting to find the error, I've tried rolling back the code in git, but I just cannot figure out how to debug this, it's so abstracted.

Full stack Trace:

[1] Symfony\Component\PropertyAccess\Exception\UnexpectedTypeException: Expected argument of type "object or array", "NULL" given
    at n/a
        in /srv/sy4/vendor/symfony/symfony/src/Symfony/Component/PropertyAccess/PropertyAccessor.php line 232

    at Symfony\Component\PropertyAccess\PropertyAccessor->readPropertiesUntil(object(User), object(PropertyPath), '2', true)
        in /srv/sy4/vendor/symfony/symfony/src/Symfony/Component/PropertyAccess/PropertyAccessor.php line 58

    at Symfony\Component\PropertyAccess\PropertyAccessor->getValue(object(User), object(PropertyPath))
        in /srv/sy4/vendor/symfony/symfony/src/Symfony/Component/Form/Extension/Core/ChoiceList/ObjectChoiceList.php line 252

    at Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList->extractLabels(array(object(User), object(User), object(User), object(User), object(User), object(User), object(User), object(User), object(User), object(User), object(User), object(User), object(User), object(User), object(User), object(User)), array('test test', 'test test', 'test test', 'Coughlin Tom', 'test test', 'Smith John', 'Eric Spoelstra', 'James LeBron', 'Chris Bosh', 'Roy Ronalds', 'Development Preview', 'Roy Testing', 'Tester TesterLast'))
        in /srv/sy4/vendor/symfony/symfony/src/Symfony/Component/Form/Extension/Core/ChoiceList/ObjectChoiceList.php line 146

    at Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList->initialize(array(object(User), object(User), object(User), object(User), object(User), object(User), object(User), object(User), object(User), object(User), object(User), object(User), object(User), object(User), object(User), object(User)), array(), array())
        in /srv/sy4/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php line 437

    at Symfony\Bridge\Doctrine\Form\ChoiceList\EntityChoiceList->load()
        in /srv/sy4/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php line 174

    at Symfony\Bridge\Doctrine\Form\ChoiceList\EntityChoiceList->getPreferredViews()
        in /srv/sy4/vendor/symfony/symfony/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php line 101

    at Symfony\Component\Form\Extension\Core\Type\ChoiceType->buildView(object(FormView), object(Form), array('block_name' => null, 'disabled' => false, 'label' => null, 'label_format' => null, 'translation_domain' => null, 'auto_initialize' => true, 'trim' => true, 'read_only' => false, 'max_length' => null, 'pattern' => null, 'property_path' => null, 'mapped' => true, 'by_reference' => true, 'virtual' => null, 'method' => 'POST', 'action' => '', 'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.', 'error_mapping' => array(), 'cascade_validation' => false, 'invalid_message' => 'This value is not valid.', 'invalid_message_parameters' => array(), 'allow_extra_fields' => false, 'extra_fields_message' => 'This form should not contain extra fields.', 'csrf_protection' => true, 'csrf_field_name' => '_token', 'csrf_message' => 'The CSRF token is invalid. Please try to resubmit the form.', 'csrf_provider' => object(CsrfProviderAdapter), 'intention' => null, 'multiple' => false, 'expanded' => false, 'choices' => null, 'preferred_choices' => array(), 'query_builder' => null, 'group_by' => null, 'attr' => array(), 'data_class' => null, 'empty_data' => '', 'required' => false, 'error_bubbling' => false, 'label_attr' => array(), 'inherit_data' => false, 'compound' => false, 'validation_groups' => null, 'constraints' => array(), 'csrf_token_manager' => object(CsrfProviderAdapter), 'csrf_token_id' => null, 'property' => 'profile.fullname', 'class' => 'SYUsersBundle:User', 'em' => object(EntityManager), 'loader' => object(ORMQueryBuilderLoader), 'choice_list' => object(EntityChoiceList), 'empty_value' => '', 'placeholder' => ''))
        in /srv/sy4/vendor/symfony/symfony/src/Symfony/Component/Form/ResolvedFormType.php line 162

    at Symfony\Component\Form\ResolvedFormType->buildView(object(FormView), object(Form), array('block_name' => null, 'disabled' => false, 'label' => null, 'label_format' => null, 'translation_domain' => null, 'auto_initialize' => true, 'trim' => true, 'read_only' => false, 'max_length' => null, 'pattern' => null, 'property_path' => null, 'mapped' => true, 'by_reference' => true, 'virtual' => null, 'method' => 'POST', 'action' => '', 'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.', 'error_mapping' => array(), 'cascade_validation' => false, 'invalid_message' => 'This value is not valid.', 'invalid_message_parameters' => array(), 'allow_extra_fields' => false, 'extra_fields_message' => 'This form should not contain extra fields.', 'csrf_protection' => true, 'csrf_field_name' => '_token', 'csrf_message' => 'The CSRF token is invalid. Please try to resubmit the form.', 'csrf_provider' => object(CsrfProviderAdapter), 'intention' => null, 'multiple' => false, 'expanded' => false, 'choices' => null, 'preferred_choices' => array(), 'query_builder' => null, 'group_by' => null, 'attr' => array(), 'data_class' => null, 'empty_data' => '', 'required' => false, 'error_bubbling' => false, 'label_attr' => array(), 'inherit_data' => false, 'compound' => false, 'validation_groups' => null, 'constraints' => array(), 'csrf_token_manager' => object(CsrfProviderAdapter), 'csrf_token_id' => null, 'property' => 'profile.fullname', 'class' => 'SYUsersBundle:User', 'em' => object(EntityManager), 'loader' => object(ORMQueryBuilderLoader), 'choice_list' => object(EntityChoiceList), 'empty_value' => '', 'placeholder' => ''))
        in /srv/sy4/vendor/symfony/symfony/src/Symfony/Component/Form/Extension/DataCollector/Proxy/ResolvedTypeDataCollectorProxy.php line 111

    at Symfony\Component\Form\Extension\DataCollector\Proxy\ResolvedTypeDataCollectorProxy->buildView(object(FormView), object(Form), array('block_name' => null, 'disabled' => false, 'label' => null, 'label_format' => null, 'translation_domain' => null, 'auto_initialize' => true, 'trim' => true, 'read_only' => false, 'max_length' => null, 'pattern' => null, 'property_path' => null, 'mapped' => true, 'by_reference' => true, 'virtual' => null, 'method' => 'POST', 'action' => '', 'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.', 'error_mapping' => array(), 'cascade_validation' => false, 'invalid_message' => 'This value is not valid.', 'invalid_message_parameters' => array(), 'allow_extra_fields' => false, 'extra_fields_message' => 'This form should not contain extra fields.', 'csrf_protection' => true, 'csrf_field_name' => '_token', 'csrf_message' => 'The CSRF token is invalid. Please try to resubmit the form.', 'csrf_provider' => object(CsrfProviderAdapter), 'intention' => null, 'multiple' => false, 'expanded' => false, 'choices' => null, 'preferred_choices' => array(), 'query_builder' => null, 'group_by' => null, 'attr' => array(), 'data_class' => null, 'empty_data' => '', 'required' => false, 'error_bubbling' => false, 'label_attr' => array(), 'inherit_data' => false, 'compound' => false, 'validation_groups' => null, 'constraints' => array(), 'csrf_token_manager' => object(CsrfProviderAdapter), 'csrf_token_id' => null, 'property' => 'profile.fullname', 'class' => 'SYUsersBundle:User', 'em' => object(EntityManager), 'loader' => object(ORMQueryBuilderLoader), 'choice_list' => object(EntityChoiceList), 'empty_value' => '', 'placeholder' => ''))
        in /srv/sy4/vendor/symfony/symfony/src/Symfony/Component/Form/ResolvedFormType.php line 159

    at Symfony\Component\Form\ResolvedFormType->buildView(object(FormView), object(Form), array('block_name' => null, 'disabled' => false, 'label' => null, 'label_format' => null, 'translation_domain' => null, 'auto_initialize' => true, 'trim' => true, 'read_only' => false, 'max_length' => null, 'pattern' => null, 'property_path' => null, 'mapped' => true, 'by_reference' => true, 'virtual' => null, 'method' => 'POST', 'action' => '', 'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.', 'error_mapping' => array(), 'cascade_validation' => false, 'invalid_message' => 'This value is not valid.', 'invalid_message_parameters' => array(), 'allow_extra_fields' => false, 'extra_fields_message' => 'This form should not contain extra fields.', 'csrf_protection' => true, 'csrf_field_name' => '_token', 'csrf_message' => 'The CSRF token is invalid. Please try to resubmit the form.', 'csrf_provider' => object(CsrfProviderAdapter), 'intention' => null, 'multiple' => false, 'expanded' => false, 'choices' => null, 'preferred_choices' => array(), 'query_builder' => null, 'group_by' => null, 'attr' => array(), 'data_class' => null, 'empty_data' => '', 'required' => false, 'error_bubbling' => false, 'label_attr' => array(), 'inherit_data' => false, 'compound' => false, 'validation_groups' => null, 'constraints' => array(), 'csrf_token_manager' => object(CsrfProviderAdapter), 'csrf_token_id' => null, 'property' => 'profile.fullname', 'class' => 'SYUsersBundle:User', 'em' => object(EntityManager), 'loader' => object(ORMQueryBuilderLoader), 'choice_list' => object(EntityChoiceList), 'empty_value' => '', 'placeholder' => ''))
        in /srv/sy4/vendor/symfony/symfony/src/Symfony/Component/Form/Extension/DataCollector/Proxy/ResolvedTypeDataCollectorProxy.php line 111

    at Symfony\Component\Form\Extension\DataCollector\Proxy\ResolvedTypeDataCollectorProxy->buildView(object(FormView), object(Form), array('block_name' => null, 'disabled' => false, 'label' => null, 'label_format' => null, 'translation_domain' => null, 'auto_initialize' => true, 'trim' => true, 'read_only' => false, 'max_length' => null, 'pattern' => null, 'property_path' => null, 'mapped' => true, 'by_reference' => true, 'virtual' => null, 'method' => 'POST', 'action' => '', 'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.', 'error_mapping' => array(), 'cascade_validation' => false, 'invalid_message' => 'This value is not valid.', 'invalid_message_parameters' => array(), 'allow_extra_fields' => false, 'extra_fields_message' => 'This form should not contain extra fields.', 'csrf_protection' => true, 'csrf_field_name' => '_token', 'csrf_message' => 'The CSRF token is invalid. Please try to resubmit the form.', 'csrf_provider' => object(CsrfProviderAdapter), 'intention' => null, 'multiple' => false, 'expanded' => false, 'choices' => null, 'preferred_choices' => array(), 'query_builder' => null, 'group_by' => null, 'attr' => array(), 'data_class' => null, 'empty_data' => '', 'required' => false, 'error_bubbling' => false, 'label_attr' => array(), 'inherit_data' => false, 'compound' => false, 'validation_groups' => null, 'constraints' => array(), 'csrf_token_manager' => object(CsrfProviderAdapter), 'csrf_token_id' => null, 'property' => 'profile.fullname', 'class' => 'SYUsersBundle:User', 'em' => object(EntityManager), 'loader' => object(ORMQueryBuilderLoader), 'choice_list' => object(EntityChoiceList), 'empty_value' => '', 'placeholder' => ''))
        in /srv/sy4/vendor/symfony/symfony/src/Symfony/Component/Form/Form.php line 1058

    at Symfony\Component\Form\Form->createView(object(FormView))
        in /srv/sy4/vendor/symfony/symfony/src/Symfony/Component/Form/Form.php line 1061

    at Symfony\Component\Form\Form->createView()
        in /srv/sy4/src/SK/AdminBundle/Controller/CrudController.php line 100

    at SK\AdminBundle\Controller\CrudController->doIndex()
        in /srv/sy4/src/SK/AdminBundle/Controller/CrudController.php line 30

    at SK\AdminBundle\Controller\CrudController->indexAction()
        in  line 

    at call_user_func_array(array(object(TeamsController), 'indexAction'), array())
        in /srv/sy4/app/bootstrap.php.cache line 3039

    at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
        in /srv/sy4/app/bootstrap.php.cache line 3001

    at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
        in /srv/sy4/app/bootstrap.php.cache line 3150

    at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true)
        in /srv/sy4/app/bootstrap.php.cache line 2391

    at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
        in /srv/sy4/web/app_dev.php line 28

enter image description here


Solution

  • Seems like it's trying to render a form type with a choices field (for a user object) but the choices are empty(null). Can you post your config for the form type, specifically the part with a choice field of users.