Remove calls to clearstatcache in \Drupal\Tests\file\Functional\FileFieldRevisionTest::testRevisions

Created on 30 January 2024, 10 months ago
Updated 13 February 2024, 9 months ago

Problem/Motivation

The function signature for clearstatcache is clearstatcache(bool $clear_realpath_cache = false, string $filename = ''): void but in FileFieldRevisionTest::testRevisions it is called 4 times with only a string file URI.

Since these filename strings would be truthy that would be equivalent of passing TRUE for the $clear_realpath_cache argument, meaning we are clearing the entire stat cache and realpath cache 4 times!

Moreover, there is a todo comment above these calls that suggests the calls should not be necessary:

// TODO: This seems like a bug in File API. Clearing the stat cache should
// not be necessary here. The file really is deleted, but stream wrappers
// doesn't seem to think so unless we clear the PHP file stat() cache.

The test still passes after removing these calls, so that confirms they are not necessary.

Steps to reproduce

Proposed resolution

Remove calls to clearstatcache

Merge request link

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Fixed

Version

10.2

Component
File system 

Last updated about 11 hours ago

Created by

🇦🇺Australia mstrelan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024