Ensure render-cached items work correctly

Created on 7 January 2026, 8 days ago

Motivation

I found this code snippet in a private project:

/**
 * Implements hook_custom_element_entity_defaults_alter().
 *
 * Since custom_elements does not use entity rendering, re-add support for
 * entity render history.
 *
 * @see views_exclude_previous_entity_build_defaults_alter()
 */
function MODULE_custom_element_entity_defaults_alter(CustomElement $element, EntityInterface $entity) {
  // Note that we use hook_entity_build_defaults_alter() as this runs even
  // when the entity is in render cache.
  $render_history = \Drupal::service('views_exclude_previous.render_history');
  assert($render_history instanceof EntityRenderHistory);
  $render_history->add($entity);
}

This should not be necessary, let's make the module itself impelment this hook if needed.

📌 Task
Status

Active

Version

3.0

Component

Code

Created by

🇦🇹Austria fago Vienna

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024