-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Doctrine][4.4] Documentation not clear about how to use "metadata_cache_driver" (May result in Unknown cache of type "array" configured for cache "metadata_cache" in entity manager "default".) #12788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
If i understand the related <?php
// ...
// around line 723
switch ($cacheDriver['type'] ?? 'pool') {
case 'service':
$serviceId = $cacheDriver['id'];
break;
case 'pool':
$serviceId = $this->createPoolCacheDefinition($container, $cacheDriver['pool'] ?? $this->createArrayAdapterCachePool($container, $objectManagerName, $cacheName));
break;
case 'provider':
$serviceId = sprintf('doctrine_cache.providers.%s', $cacheDriver['cache_provider']);
break;
default:
throw new \InvalidArgumentException(sprintf(
'Unknown cache of type "%s" configured for cache "%s" in entity manager "%s".',
$cacheDriver['type'],
$cacheName,
$objectManagerName
));
}
?> Source: https://github.com/doctrine/DoctrineBundle/blob/2.0.x/DependencyInjection/DoctrineExtension.php#L716 |
Possible solution?As described here, one just has to install
to solve the problem. Dont forget to clear your cache folder before trying it out! As mentioned before, with It worked for me together with the following changes: config/doctrine.yamldoctrine:
dbal:
# configure these for your database server
driver: 'pdo_mysql'
server_version: '5.7'
charset: utf8mb4
url: '%env(resolve:DATABASE_URL)%'
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_520_ci
orm:
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_generate_proxy_classes: false
metadata_cache_driver: # <=== new
type: service
id: doctrine.system_cache_provider
query_cache_driver: # <=== new
type: service
id: doctrine.system_cache_provider
result_cache_driver: # <=== new
type: service
id: doctrine.result_cache_provider
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/App/Entity'
prefix: 'App\Entity'
alias: App config/services.yamlservices:
# ...
doctrine.result_cache_provider: # <==== new
class: Symfony\Component\Cache\DoctrineProvider
public: false
arguments:
- '@doctrine.result_cache_pool'
doctrine.system_cache_provider: # <==== new
class: Symfony\Component\Cache\DoctrineProvider
public: false
arguments:
- '@doctrine.system_cache_pool' config/framework.yamlframework:
cache:
# ....
pools: # <==== new
doctrine.result_cache_pool:
adapter: cache.app
doctrine.system_cache_pool:
adapter: cache.system Can someone tell me, why i have to install Shouldn't these information be added to the documentation? What do you think? |
Any feedback on this please? |
I understand the docs in such a way that your solution of defining a service per cache pool is equivalent to configuring
and omitting the service definition.
|
Thank you for this issue. |
On the Doctrine configuration page (https://symfony.com/doc/4.4/reference/configuration/doctrine.html) it states to use the following configuration to setup Doctrine:
But when using it, i get the following error:
Here is my configuration:
About my setup:
I also tried #10797, but it didn't help. Using
metadata_cache_driver
indoctrine.orm
results in:Did i missed something in the documentation?
EDIT: When running in
dev
environment, i had no problems, but after i started with PHPUnit tests requiring Doctrine, i ran into the error above.The text was updated successfully, but these errors were encountered: