Symfony 4.4中metadata_cache_driver配置键已经弃用,请注意。

5
自从我将Symfony从4.4.15升级到4.4.16后,我收到了以下的弃用通知:
“metadata_cache_driver”配置键已弃用。当%kernel.debug%为false时,PHP数组缓存现在会自动注册。
这很奇怪,因为官方文档除了这段文字外,没有关于此弃用的说明:
从版本4.4开始弃用:所有Doctrine缓存类型都从Symfony 4.4开始弃用,并且在Symfony 5.0及更高版本中将不可用。请使用类型:service或类型:pool替换它们,并使用Symfony Cache定义的任何缓存池/服务之一。
但是我正在使用缓存类型池或服务。我的配置如下:
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

我甚至尝试将缓存配置为服务,如下所示,但仍收到相同的弃用通知:

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

有什么办法可以摆脱弃用通知?


这个问题没有任何问题,也不要被踩票所困扰。这是添加弃用通知的拉取请求:https://github.com/doctrine/DoctrineBundle/pull/1196。这可能会提供一些信息。 - Stephan Vierkant
2个回答

6

实际上,已经取消了弃用操作:https://github.com/doctrine/DoctrineBundle/pull/1255

因此,请确保在升级到DoctrineBundle 2.2.1时,保留metadata_cache_driver配置用于生产环境。

编辑:该功能已在DoctrineBundle的2.3.0版本中重新发布。因此,在使用此版本时,可以安全地删除metadata_cache_driver配置用于生产环境。


你知道在生产环境中删除metadata_cache_driver条目是否安全,或者是否需要删除吗?在开发环境中收到以下弃用通知:“metadata_cache_driver”配置键已弃用。当%kernel.debug%为false时,PHP数组缓存现在会自动注册。 - ninsky
1
@ninsky确实,当使用版本2.3.0时,您可以删除配置选项,因为该功能已重新发布。我已更新上面的评论。 - dmaicher

4

从 DoctrineBundle 2.2.0 版本开始,您可以安全地从配置中删除 metadata_cache_driver,无需替换,只需将其删除即可。

这个弃用通知是通过 pull request 引入的,并给出了一些解释:"之所以需要更改是因为从现在开始定义自己的 metadata_cache_driver 是无用的。"

Doctrine 现在在生产环境中使用 PhpArrayAdapter。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接