I have many errors like this one in the latest master on PHP 7 :
[2016-12-02 12:58:33] php.CRITICAL: Uncaught Exception: Serialization of 'Closure' is not allowed {"exception":"[object] (Exception(code: 0): Serialization of 'Closure' is not allowed at /vendor/zendframework/zend-stdlib/src/PriorityQueue.php:178)"} []
and no stack trace to try to find the error (the debugger does not load) :/
I have looked around what could be the problem and I found that the Form component might not like function closures for choices. Sonata reportedly had the same problem and they fixed it here (See related discussion here).
Not sure if the problem is in Sylius directly but it could be in code like this one :
public function configureOptions(OptionsResolver $resolver)
{
$resolver
->setDefaults([
'choices' => function (Options $options) {
if (null === $options['enabled']) {
return $this->countryRepository->findAll();
}
return $this->countryRepository->findBy(['enabled' => $options['enabled']]);
},
'choice_value' => 'code',
'choice_label' => 'name',
'choice_translation_domain' => false,
'enabled' => true,
'label' => 'sylius.form.address.country',
'placeholder' => 'sylius.form.country.select',
])
;
}
(see for instance https://github.com/Sylius/Sylius/blob/8a2e157498d11aece5b4f3beacdc9705dd01d91a/src/Sylius/Bundle/AddressingBundle/Form/Type/CountryChoiceType.php#L45)
Anybody encountered the same error ?
Thanks
Thanks for reporting, we should definitely fix that. We will have a look at it soon! :)
Looks like symfony issue (https://github.com/symfony/symfony/issues/20698). Can you check if https://github.com/symfony/symfony/pull/20700 resolves it?
I have manually patched the related files in the merged PR but to no avail ..
@nicolas-grekas is going to work on a solution (https://github.com/symfony/symfony/issues/20698#issuecomment-264642928), let's move the discussion there.
Should be solved by https://github.com/symfony/symfony/pull/20762.
Yep, it is - Hope this will be tagged soon. Closing this one since it's not _Sylius-related_. Thanks for your help @michalmarcinkowski
Most helpful comment
Yep, it is - Hope this will be tagged soon. Closing this one since it's not _Sylius-related_. Thanks for your help @michalmarcinkowski