Change record status: 
Project: 
Introduced in branch: 
11.2.x
Introduced in version: 
11.2.0
Description: 

Similar to many other static caches, statically cached entities are now automatically cleared as part of the core/lib/Drupal/Core/Test/RefreshVariablesTrait.php::refreshVariables() method, which is typically called when submitting forms in web tests but can also be called explicitly.

This means that it is no longer required to explicitly clear static caches before reloading an entity in such tests:

Example from the core issue


     $this->drupalGet('comment/' . $comment->id() . '/edit');
     $this->submitForm($user_edit, 'Save');
-    $comment_storage->resetCache([$comment->id()]);
     $comment_loaded = Comment::load($comment->id());

Existing tests that explicitly invalidate caches should continue to work and may be optimized to remove these calls once they require Drupal 11.2+.

This might cause failures in tests if those tests incorrectly relied on static cache masking a problem in the implementation or test code or if they explicitly assert the behavior of the static cache.

Impacts: 
Module developers