Document that it's not allowed to trigger theme functions in hook_entity_info_alter()

Created on 5 December 2012, about 12 years ago
Updated 4 August 2024, 5 months ago

Problem/Motivation

API page: http://api.drupal.org/api/drupal/modules%21system%21system.api.php/funct...

If a module triggers a theme function in its implementation of hook_entity_info this breaks different things.
It's the cause for various strange bugs:

  • it breaks theme switching like the core's administration theme feature when the caches are cleared
  • if you use a contrib theme switching module the first request after "cache clear all" creates a page cache entry using the default theme instead of the right one
  • "themed entries" in the entity cache are always cached using the theme that was active at this moment

The cause is always a call of a theme function (or l() which triggers a theme function). In some cases it intializes the theme engine too early in the boot process. In another case it uses an already initialized "wrong" theme.

Proposed resolution

There're already various bug reports for contrib modules and core which could not be reproduced unless you install a contrib module that uses a theme function in its hook_entity_info(), for example:

  • #1222536
  • #1702008
  • #1463010
  • #1370964
  • Bugs reported in e.g. commerce_paypal_wps and commerce_novalnet_elv_de_pci.

We want to file issues for these modules but they're more likely to be accepted as such if the documentation states that theming is not permitted in that hook.

Afterwards we can clear the issue queues of the other modules and core where people reported these strange bugs not caused by these modules themselves.

Remaining tasks

Is this still relevant?

User interface changes

None.

API changes

None.

Data model changes

None.

📌 Task
Status

Postponed: needs info

Version

11.0 🔥

Component
Documentation 

Last updated 1 day ago

No maintainer
Created by

🇩🇪Germany mkalkbrenner 🇩🇪

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.

  • 🇳🇿New Zealand quietone

    The last comment here, 6 years ago, questions whether this issue is still relevant.

    I am setting the status to Postponed (maintainer needs more info). If we don't receive additional information to confirm that this still needs to be done, it may be closed after three months.

Production build 0.71.5 2024