Problem/Motivation

While troubleshooting performance problems on a complex website with many entities loaded due to a lot of relationships, I noticed that they were some SQL queries related to entity_translation in doublon.
By investigating more in depth I noticed that it was caused by the invoking of the hook entity_load on entity_translation systematically from the title_entity_load hook.

My understanding of the code flow is while loading an entity through entity_load
- as title_module_implements_alter implementation specifies that the entity_translation's implementation of hook_entity_load should be executed before
- the entity_translation's implementation of hook_entity_load hook is already executed prior to title's one
- so there's no need to ask again if it has already been gathered.

Steps to reproduce

use a debugger and put a breakpoint in entity_translation_entity_load then load a page with a title: you should pass two times in the hook.

Proposed resolution

My proposal is to add a check of the presence of the translations data structure in each entity loaded in order to (re) launch the hook only if really needed.
The patch joined should fix it.

User interface changes

none

API changes

none

Data model changes

none

Hope it helps
Best regards

Comments

ceonizm created an issue. See original summary.

ram4nd’s picture

Status: Active » Needs review
Issue tags: -Page loading performance