Doctrinebundle: Can't clear metadata with DoctrineBundle 2.2.0 (prod)

Created on 10 Nov 2020  路  8Comments  路  Source: doctrine/DoctrineBundle

As of DoctrineBundle 2.2, I get an error message when running bin/console doctrine:cache:clear-metadata in prod environment. Must be related to #1196, but I don't know what's going wrong, since the error message isn't very helpfull:

[ERROR] No cache entries were deleted.

The problem is that \Symfony\Component\Cache\Adapter\PhpArrayAdapter::save returns false, but I don't understand why.

Ready to work on

All 8 comments

Cannot reproduce :/

root@6639ad92298f:/var/www# php -m | grep OPcache
Zend OPcache
Zend OPcache
root@6639ad92298f:/var/www# bin/console doctrine:cache:clear-metadata --env=prod

 // Clearing all Metadata cache entries


 [OK] Successfully deleted cache entries.


root@6639ad92298f:/var/www# php -m | grep OPcache
Zend OPcache
Zend OPcache
root@6639ad92298f:/var/www# composer show doctrine/doctrine-bundle | grep versions
versions : * 2.2.0
root@6639ad92298f:/var/www#

Alright to reproduce this cache warmup needs to be run too

We decided to rollback the change which caused this issue. We released 2.2.1 which should fix your issue.

@stephanvierkant Since we started using PhpArray cache adapter and it stored in opcache we can't clear metadata cache the same as using for example APCu cache. Therefore PhpArrayAdapter::save returns false.

We shouldn't ship it if it breaks cache clearing though, no matter what internal details prevent it. I think wiping the cache might be important for users.

@ostrolucky Actually clearing matadata cache already has some restrictions, not every cache adapter can clear it: https://github.com/doctrine/orm/blob/2.7/lib/Doctrine/ORM/Tools/Console/Command/ClearCache/MetadataCommand.php#L84-L90
Metadata on the production environment should not be changed as well as all other code, so IMO clearing metadata cache does not make sence.
Since we deprecated metadata_cache_driver configuration I think we also should deprecate this command.
Or the second solution we can set php array adapter in metadata_cache_driver configuration thus allowing the user to choose the cache adapter himself. But such using of php array adapter is different from the accepted use in a Symfony.

@stephanvierkant Could you please describe a case when you need clear metadata cache on production?

I haven't checked if it is necessary, but it is part of my composer post update/install script. Maybe it's legacy code, since the project started with Symfony 2.x.

Yeah deprecating the command would be acceptable I think

Was this page helpful?
0 / 5 - 0 ratings