diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index b786923b8e045..b390f2978113b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -53,6 +53,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\ExpressionLanguage\ExpressionLanguage; use Symfony\Component\Finder\Finder; +use Symfony\Component\Form\ChoiceList\Factory\CachingFactoryDecorator; use Symfony\Component\Form\FormTypeExtensionInterface; use Symfony\Component\Form\FormTypeGuesserInterface; use Symfony\Component\Form\FormTypeInterface; @@ -410,6 +411,11 @@ private function registerFormConfiguration(array $config, ContainerBuilder $cont if (!class_exists(Translator::class)) { $container->removeDefinition('form.type_extension.upload.validator'); } + if (!method_exists(CachingFactoryDecorator::class, 'reset')) { + $container->getDefinition('form.choice_list_factory.cached') + ->clearTag('kernel.reset') + ; + } } private function registerEsiConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml index a375e527ce323..4ca196e47d3ea 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml @@ -57,6 +57,7 @@ + diff --git a/src/Symfony/Component/Form/ChoiceList/Factory/CachingFactoryDecorator.php b/src/Symfony/Component/Form/ChoiceList/Factory/CachingFactoryDecorator.php index 477afbbb07879..65d17afbdf0e7 100644 --- a/src/Symfony/Component/Form/ChoiceList/Factory/CachingFactoryDecorator.php +++ b/src/Symfony/Component/Form/ChoiceList/Factory/CachingFactoryDecorator.php @@ -14,13 +14,14 @@ use Symfony\Component\Form\ChoiceList\ChoiceListInterface; use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface; use Symfony\Component\Form\ChoiceList\View\ChoiceListView; +use Symfony\Contracts\Service\ResetInterface; /** * Caches the choice lists created by the decorated factory. * * @author Bernhard Schussek */ -class CachingFactoryDecorator implements ChoiceListFactoryInterface +class CachingFactoryDecorator implements ChoiceListFactoryInterface, ResetInterface { private $decoratedFactory; @@ -134,4 +135,10 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null, return $this->views[$hash]; } + + public function reset() + { + $this->lists = []; + $this->views = []; + } }