Multilingual Auto Label Corrupts Entity Static Caches

Created on 30 June 2014, almost 11 years ago
Updated 5 January 2025, 3 months ago

I've been pulling my hair out on this one for weeks, but I've finally figured it out.

Setup:

Using auto_entitylabel on a multilingual site which uses translated name values of taxonomy terms in the generated paths via pathauto. Saving a node sometimes results in generated paths with the term names translated in the incorrect languages. This is because during auto_entitylabel_set_title(), the multilingual titles are generated by token_replace() and entity_token_tokens(), an implementation of hook_token() hooks into this and creates metadata wrapper objects around relevant entities, caching objects in the process.

Placing the following code immediately after the multilingual title generation (around line 211 in entity_autolabel.module) fixes the problem, but also adds a significant amount of overhead as we are purging all static entity caches. If someone knows a better, more targeted method, I would suggest using that. In the meantime, I hope this can help another developer from going bald.


      //Clear entity static caches, which now have been corrupted with translated versions of entities from above.
      $entiy_info = entity_get_info();
      $entity_types = array_keys($entiy_info);
      foreach ($entity_types as $entity_type) {
        $entity_controller = entity_get_controller($entity_type);
        $entity_controller->resetCache();
      }

πŸ› Bug report
Status

Closed: outdated

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States bburg Washington D.C.

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.

Production build 0.71.5 2024