You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are having an issue with the entity access cache containing stale items in Behat scenarios. The problem occurs in the following circumstances (all the following steps are executed in a single Behat scenario, i.e. in a single Drupal request)
Use an entity type which implements EntityPublishedInterface does not implement RevisionableInterface.
Create an unpublished entity.
View the entity with a user which does not have permission to view unpublished entities.
Publish the entity.
View the entity again with the same user.
Expected result: the user should see the entity.
Actual result: the entity is invisible.
This is caused by the static cache of EntityAccessControlHandler. The access status of entities are cached using a cache ID that is comprised of the UUID or {entity_type_id}:{entity_id}. In case of a revisionable entity type the revision ID is also appended to the cache ID.
In the following circumstances this works fine:
When using Drupal through the UI - the static cache only lives as long as a single request, and on subsequent requests it is rebuilt. It is unlikely to hit stale caches in these circumstances.
When using revisionable entities the cache ID changes as soon as the entity is published, and the stale cache entry is never hit.
However in a case of using a non-revisioned entity inside a long running process such as a Behat test these stale caches become a problem.
Suggested solution: clear the EntityAccessControlHandler static cache in \Drupal\Driver\Cores\Drupal8::clearStaticCaches() so that developers can decide to clear the caches in a related step definition or hook.
The text was updated successfully, but these errors were encountered:
pfrenssen
added a commit
to pfrenssen/DrupalDriver
that referenced
this issue
Jun 22, 2020
We are having an issue with the entity access cache containing stale items in Behat scenarios. The problem occurs in the following circumstances (all the following steps are executed in a single Behat scenario, i.e. in a single Drupal request)
EntityPublishedInterface
does not implementRevisionableInterface
.Expected result: the user should see the entity.
Actual result: the entity is invisible.
This is caused by the static cache of
EntityAccessControlHandler
. The access status of entities are cached using a cache ID that is comprised of the UUID or{entity_type_id}:{entity_id}
. In case of a revisionable entity type the revision ID is also appended to the cache ID.In the following circumstances this works fine:
However in a case of using a non-revisioned entity inside a long running process such as a Behat test these stale caches become a problem.
Suggested solution: clear the
EntityAccessControlHandler
static cache in\Drupal\Driver\Cores\Drupal8::clearStaticCaches()
so that developers can decide to clear the caches in a related step definition or hook.The text was updated successfully, but these errors were encountered: