Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

clearByTags in Filesystem adapter crashes when .tag file deleted during GlobIterator loop #44

@skors

Description

@skors

Hi,

we see the following error when using Filesystem storage adapter and deleting a large set of object from cache with clearByTags() method.

// when file_locking is off in File Zend/Cache/Storage/Adapter/Filesystem.php in line 1363
file_get_contents(my_cache_dir/my_cached_object_4711.tag): failed to open stream: No such file or directory
// when file_locking is on in File Zend/Cache/Storage/Adapter/Filesystem.php in line 1327
fopen(my_cache_dir/my_cached_object_4711.tag): failed to open stream: No such file or directory

It is not that easy to reproduce but occurs as follows:

  • the GlobIterator in clearByTags() looks for all .tag files which holds the cached item tags information
  • while looping through these items, another process deletes one item (and its .tag file) which is also prior found by the GlobIterator
  • clearByTags triggers an error at $this->getFileContent($pathname) because fopen() or file_get_contents try to open a non existing file (not existing anymore)

Should be simple be avoided by adding

if (!file_exists($file)) { // or !$glob->valid()?
    continue;
}

to the foreach loop in clearByTags(), but is this right?

I also can submit a PR, but until now i do not have found a way to reproduce for a unit test

cheers

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions