5

Since I've upgraded Symfony from 4.4.15 to 4.4.16 I've got following deprecation notice:

The "metadata_cache_driver" configuration key is deprecated. PHP Array cache is now automatically registered when %kernel.debug% is false.

This is strange as the official docs don't say anything about this deprecation except of this text:

Deprecated since version 4.4:All the Doctrine caching types are deprecated since Symfony 4.4 and won’t be available in Symfony 5.0 and higher. Replace them with either type: service or type: pool and use any of the cache pools/services defined with Symfony Cache.

But I'm using caching type pool or service. My configuration looks like this:

doctrine:  
    orm:  
        metadata_cache_driver:
            type: pool
            pool: doctrine.system_cache_pool  

framework:
    cache:
        default_memcached_provider: 'memcached://localhost:11211'
        pools:
            doctrine.system_cache_pool:
                adapter: cache.adapter.memcached
                public: false
                default_lifetime: 86400

I even tried to config the cache as a service like this which gives me the same deprecation notice:

doctrine:
    orm:    
        metadata_cache_driver:
            type: service
            id: doctrine.system_cache_provider

services:
    doctrine.system_cache_provider:
        class: Symfony\Component\Cache\DoctrineProvider
        public: false
        arguments:
            - '@doctrine.system_cache_pool'

framework:
    cache:
        default_memcached_provider: 'memcached://localhost:11211'
        pools:
            doctrine.system_cache_pool:
                adapter: cache.adapter.memcached
                public: false
                default_lifetime: 86400

Any ideas how to get rid of the deprecation notice?

ninsky
  • 1,772
  • 23
  • 31
  • Nothing wrong with this question, don't get the downvote either. Here is the pull request that added the deprecation notice: https://github.com/doctrine/DoctrineBundle/pull/1196. That might give some information. – Stephan Vierkant Nov 10 '20 at 11:42

2 Answers2

6

Actually the deprecation was reverted: https://github.com/doctrine/DoctrineBundle/pull/1255

So please make sure to keep the metadata_cache_driver config for your production environments when upgrading to DoctrineBundle 2.2.1.

EDIT: The feature was released again with version 2.3.0 of DoctrineBundle. So the metadata_cache_driver config can safely be removed for prod environments when using this version.

dmaicher
  • 156
  • 4
  • Do you know if it's save to remove the metadata_cache_driver entry or is the removal necessary at all on PROD? Getting following deprecation notice on DEV: "The "metadata_cache_driver" configuration key is deprecated. PHP Array cache is now automatically registered when %kernel.debug% is false" – ninsky Mar 22 '21 at 14:19
  • 1
    @ninsky indeed when using version 2.3.0 you can remove the config option as the feature was released again. I updated my comment above. – dmaicher Mar 23 '21 at 20:40
4

As of DoctrineBundle 2.2.0 you can safely remove metadata_cache_driver from your configuration. There is no replacement; just delete it.

The pull request that introduced this deprecation notice gives some explanation: "Change is needed because defining own metadata_cache_driver is useless from now on."

Doctrine now uses PhpArrayAdapter in production environment.

Stephan Vierkant
  • 9,674
  • 8
  • 61
  • 97