Skip to content

cache:pool:clear never fails on permission errors #39890

Closed
@Bilge

Description

@Bilge

Symfony version(s) affected: 5.2.0

Description
cache:pool:clear does not report an error when it fails to clear cache. Specifically, if the current user does not have permission to modify a cache file on disk, it still reports success. However, the same is not true of cache:pool:delete.

How to reproduce

bin/console cache:pool:delete cache.app foo

11:11:37 WARNING   [cache] Failed to delete key "foo". ["key" => "foo","exception" => null,"cache-adapter" => "Symfony\Component\Cache\Adapter\PhpFilesAdapter"]
11:11:37 ERROR     [console] Error thrown while running command "cache:pool:delete 'cache.app' 'foo'". Message: "Cache item "foo" could not be deleted." ["exception" => Exception { …},"command" => "cache:pool:delete 'cache.app' 'foo'","message" => "Cache item "foo" could not be deleted."]

In CachePoolDeleteCommand.php line 76:

  Cache item "foo" could not be deleted.

✔️ Error reported

bin/console cache:pool:clear cache.app


 // Clearing cache pool: cache.app


 [OK] Cache was successfully cleared.

❌ Despite reporting success, cache is not actually cleared or modified in any way when the current user does not have permission to write to the cache files.

Possible Solution
Report failure if one or more items could not be deleted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions