Problem/Motivation
In #3038453-4: When RevisionableEntityBundleInterface::shouldCreateNewRevision is TRUE, create a new revision on PATCH requests and add an entry in the revision log. @Wim Leers reported:
✅ Ah,
\Drupal\Core\Entity\ContentEntityStorageBasehas a$this->latestRevisionIdsstatic cache, which without this::resetCache()call would result in the test assertions being unable to correctly assert that a revision is indeed the latest revision. Static caches strike again!
We should not need a global reset cache to be able to fetch an unchanged entity.
Proposed resolution
Fix the cache reset logic for individual entities.
Remaining tasks
- Write a patch
- Reviews
User interface changes
None
API changes
None
Data model changes
None
Release notes snippet
None
Issue fork drupal-3038706
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
plachComment #4
plachComment #5
amateescu commentedI bumped into the same problem in #2725523: Add a revision_parent field to revisionable entities and I fixed it like this:
Comment #6
wim leers#5: 👍
Comment #16
mohit_aghera commentedI came across this issue while doing bug-smash triage.
I see that we've already removed static cache in favour of memory cache in issue #3532741: Switching workspaces shouldn't clear the persistent entity cache
I believe this might not happen anymore since static cache is not in picture ?
Comment #18
longwaveYep this was removed in #3532741: Switching workspaces shouldn't clear the persistent entity cache but there is still a reference in the JSON:API tests that we need to clean up:
Repurposing this issue to do that.
Comment #19
longwaveComment #21
berdirLooks like this is causing several test fails.
This is a a different scenario I think, this is about resetting the in-memory cache to account for changes to the entity during a web request. In many cases in functional tests this now happens in web/core/lib/Drupal/Core/Test/RefreshVariablesTrait.php:25, but jsonapi tests don't trigger that.
We could optimize it a bit and only reset the specific entity that we're about to load or reset only the entity.memory service like RefreshVariablesTrait.