Attachments added in themes via hook_page_attachments_alter() can't be managed via Klaro

Created on 6 August 2025, 11 days ago

Problem/Motivation

Looks like theme hooks are called after module hooks and theme hooks are not listed in hook_module_implements_alter(), thus the current implementation in Klaro doesn't allow to manage page attachments added (or, to a limited extent, altered by) themes using hook_page_attachments_alter().

Steps to reproduce

Add a page attachment in a theme using hook_page_attachments_alter() according to the documentation also linked from the help text of the "Attachments" option in the service definition. Add the attachment id to a Klaro service. Verify that Klaro doesn't manage the attachment.

Proposed resolution

For now, probably update the help text and clarify that attachment handling doesn't work for attachments added via themes to warn users.

Investigate, if this changes with the new hook implementation in Drupal 11 and later. If so, try to support this in Drupal 11 and later. If not, file a core issue that proposes any necessary API changes so that Klaro can manage these attachments in the future.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

3.0

Component

Documentation

Created by

🇩🇪Germany FeyP

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

Comments & Activities

Production build 0.71.5 2024