<p dir="auto"><strong>Symfony version(s) affected</strong>: 3.4.20 / 4.1.9</p>
<p dir="auto">After updating from 3.4.19-&gt;3.4.20 (or 4.1.8-&gt;4.1.9) it is not possible to enable doctrine filters (<a href="https://packagist.org/packages/gedmo/doctrine-extensions" rel="nofollow">https://packagist.org/packages/gedmo/doctrine-extensions</a> + <a href="https://packagist.org/packages/stof/doctrine-extensions-bundle" rel="nofollow">https://packagist.org/packages/stof/doctrine-extensions-bundle</a>) in config.yml.<br>
Config which we use:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="filters:
  soft_deleteable:
    class: 'Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter'
    enabled: true"><pre class="notranslate"><span class="pl-ent">filters</span>:
  <span class="pl-ent">soft_deleteable</span>:
    <span class="pl-ent">class</span>: <span class="pl-s"><span class="pl-pds">'</span>Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter<span class="pl-pds">'</span></span>
    <span class="pl-ent">enabled</span>: <span class="pl-c1">true</span></pre></div>
<p dir="auto">During loading the app error is thrown:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="(1/1) InvalidArgumentExceptionFilter 'soft_deleteable' does not exist.

in FilterCollection.php line 107
at FilterCollection-&gt;enable('soft_deleteable')in ManagerConfigurator.php line 48
at ManagerConfigurator-&gt;enableFilters(object(EntityManager))in ManagerConfigurator.php line 34
at ManagerConfigurator-&gt;configure(object(EntityManager))in appDevDebugProjectContainer.php line 2714
at appDevDebugProjectContainer-&gt;getDoctrine_Orm_DefaultEntityManagerService(false)in appDevDebugProjectContainer.php line 2703
at appDevDebugProjectContainer-&gt;ContainerT6xfqgt\{closure}(null, object(EntityManager_9a5be93), 'getMetadataFactory', array(), object(Closure))in EntityManager_9a5be93.php line 38
at Closure-&gt;__invoke(null, object(EntityManager_9a5be93), 'getMetadataFactory', array(), object(Closure))in EntityManager_9a5be93.php line 38
at EntityManager_9a5be93-&gt;getMetadataFactory()in AbstractManagerRegistry.php line 181
at AbstractManagerRegistry-&gt;getManagerForClass('Path\\To\\Entity')in ServiceEntityRepository.php line 30
at ServiceEntityRepository-&gt;__construct(object(Registry), 'Path\\To\\Entity')in ServiceEntityRepository.php line 19
at SomeEntityRepository-&gt;__construct(object(Registry))in appDevDebugProjectContainer.php line 3313
at appDevDebugProjectContainer-&gt;getServiceEntityRepositoryService()in appDevDebugProjectContainer.php line 3243
at appDevDebugProjectContainer-&gt;getServiceEntityChasingPaymentServiceService()in appDevDebugProjectContainer.php line 2683
at appDevDebugProjectContainer-&gt;getDoctrine_Orm_DefaultEntityListenerResolverService()in appDevDebugProjectContainer.php line 4686
at appDevDebugProjectContainer-&gt;getDoctrine_Orm_DefaultConfigurationService()in appDevDebugProjectContainer.php line 2712
at appDevDebugProjectContainer-&gt;getDoctrine_Orm_DefaultEntityManagerService(false)in appDevDebugProjectContainer.php line 2703
at appDevDebugProjectContainer-&gt;ContainerT6xfqgt\{closure}(null, object(EntityManager_9a5be93), 'getConfiguration', array(), object(Closure))in EntityManager_9a5be93.php line 328
at Closure-&gt;__invoke(null, object(EntityManager_9a5be93), 'getConfiguration', array(), object(Closure))in EntityManager_9a5be93.php line 328
at EntityManager_9a5be93-&gt;getConfiguration()in ProxyCacheWarmer.php line 51
at ProxyCacheWarmer-&gt;warmUp('/var/www/app/default/symfony-standard/app_api/var/cache/dev')in CacheWarmerAggregate.php line 52
at CacheWarmerAggregate-&gt;warmUp('/var/www/app/default/symfony-standard/app_api/var/cache/dev')in Kernel.php line 680
at Kernel-&gt;initializeContainer()in Kernel.php line 135
at Kernel-&gt;boot()in Kernel.php line 195
at Kernel-&gt;handle(object(Request))in app_dev.php line 42"><pre class="notranslate"><code class="notranslate">(1/1) InvalidArgumentExceptionFilter 'soft_deleteable' does not exist.

in FilterCollection.php line 107
at FilterCollection-&gt;enable('soft_deleteable')in ManagerConfigurator.php line 48
at ManagerConfigurator-&gt;enableFilters(object(EntityManager))in ManagerConfigurator.php line 34
at ManagerConfigurator-&gt;configure(object(EntityManager))in appDevDebugProjectContainer.php line 2714
at appDevDebugProjectContainer-&gt;getDoctrine_Orm_DefaultEntityManagerService(false)in appDevDebugProjectContainer.php line 2703
at appDevDebugProjectContainer-&gt;ContainerT6xfqgt\{closure}(null, object(EntityManager_9a5be93), 'getMetadataFactory', array(), object(Closure))in EntityManager_9a5be93.php line 38
at Closure-&gt;__invoke(null, object(EntityManager_9a5be93), 'getMetadataFactory', array(), object(Closure))in EntityManager_9a5be93.php line 38
at EntityManager_9a5be93-&gt;getMetadataFactory()in AbstractManagerRegistry.php line 181
at AbstractManagerRegistry-&gt;getManagerForClass('Path\\To\\Entity')in ServiceEntityRepository.php line 30
at ServiceEntityRepository-&gt;__construct(object(Registry), 'Path\\To\\Entity')in ServiceEntityRepository.php line 19
at SomeEntityRepository-&gt;__construct(object(Registry))in appDevDebugProjectContainer.php line 3313
at appDevDebugProjectContainer-&gt;getServiceEntityRepositoryService()in appDevDebugProjectContainer.php line 3243
at appDevDebugProjectContainer-&gt;getServiceEntityChasingPaymentServiceService()in appDevDebugProjectContainer.php line 2683
at appDevDebugProjectContainer-&gt;getDoctrine_Orm_DefaultEntityListenerResolverService()in appDevDebugProjectContainer.php line 4686
at appDevDebugProjectContainer-&gt;getDoctrine_Orm_DefaultConfigurationService()in appDevDebugProjectContainer.php line 2712
at appDevDebugProjectContainer-&gt;getDoctrine_Orm_DefaultEntityManagerService(false)in appDevDebugProjectContainer.php line 2703
at appDevDebugProjectContainer-&gt;ContainerT6xfqgt\{closure}(null, object(EntityManager_9a5be93), 'getConfiguration', array(), object(Closure))in EntityManager_9a5be93.php line 328
at Closure-&gt;__invoke(null, object(EntityManager_9a5be93), 'getConfiguration', array(), object(Closure))in EntityManager_9a5be93.php line 328
at EntityManager_9a5be93-&gt;getConfiguration()in ProxyCacheWarmer.php line 51
at ProxyCacheWarmer-&gt;warmUp('/var/www/app/default/symfony-standard/app_api/var/cache/dev')in CacheWarmerAggregate.php line 52
at CacheWarmerAggregate-&gt;warmUp('/var/www/app/default/symfony-standard/app_api/var/cache/dev')in Kernel.php line 680
at Kernel-&gt;initializeContainer()in Kernel.php line 135
at Kernel-&gt;boot()in Kernel.php line 195
at Kernel-&gt;handle(object(Request))in app_dev.php line 42
</code></pre></div>
<p dir="auto">Looks like it is related to changes introduced in: <a href="https://github.com/symfony/symfony/pull/29369/files">https://github.com/symfony/symfony/pull/29369/files</a><br>
Note: If <code class="notranslate">enabled: true</code> is removed from the config app loads correctly, but it should be possible to have this filter enabled by default.</p>
<p dir="auto">I check Request class and seems that there is many methods runs with same arguments again and again.</p>
<p dir="auto">Like isSecure called 69 times for me and usually result is same, because $this-&gt;server and $this-&gt;headers usually same for each call. Also as many other methods in this class and class that related. For example 133 call of IpUtils::checkIp4, Request::isFromTrustedProxy and so on.</p>
<p dir="auto">I think if there is possible to make $this-&gt;server and $this-&gt;headers kind of frozen (actually they are usually don't changed during script running), than we can cache results of many methods in Request and improve performance.</p>
<p dir="auto">What do you think?</p>