- 🇯🇵Japan ptmkenny
2.x is no longer being developed, and this is not an issue for 3.x (per #7), so I'm closing this as outdated.
After updating to 8.x-2.0-alpha2, entities that contain fields that have been marked as uncacheable are still being cached.
The reason for this is the changes to the last installed definition don't happen until a field config is modified and the cacheability settings for an entity type change. Therefore we need an update script to ensure the last installed definition settings for existing entity types are set correctly.
Also, in addition to acting on field config changes, I believe we also need to ensure the correct cache settings are applied on entity type updates. If the maintainer of an entity type utilizes \Drupal\Core\Entity\EntityDefinitionUpdateManager::getEntityType()
to load the entity type definition before updating then all should be good as the field encrypt overrides should persist. But if they don't, or they modify the cache properties then entities we don't want cached could be cached again.
I have added a patch to:
EntityTypeCacheableManager
service (for lack of a better name) to consolidate the entity type cache property related logic.EntityTypeCacheableManager
service\Drupal\field_encrypt\EventSubscriber\ConfigSubscriber::setUncacheableEntityTypes()
to use the EntityTypeCacheableManager
service and only affect the entity type containing the field who's configuration was updatedHere is the code for the update method which will need to be added to the patch before it is committed:
/**
* Update all uncacheable entity types.
*
* This will ensure the last installed definition of these entity types are
* set correctly.
*
* @see \Drupal\field_encrypt\EventSubscriber\EntityTypeSubscriber::onEntityTypeUpdate()
*/
function field_encrypt_update_8201() {
$entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
$uncacheable_types = \Drupal::state()->get(EntityTypeCacheableManager::UNCACHEABLE_TYPES_STATE_KEY);
foreach ($entity_definition_update_manager->getEntityTypes() as $entity_type_id => $entity_type) {
if (array_key_exists($entity_type_id, $uncacheable_types)) {
$entity_definition_update_manager->updateEntityType($entity_type);
}
}
return t("Entity Types have been updated to account for Field Encrypt uncacheable settings.");
}
Closed: outdated
2.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
2.x is no longer being developed, and this is not an issue for 3.x (per #7), so I'm closing this as outdated.