Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 292273

_menu_link_translate() should call _menu_load_objects() just-in-time

$
0
0

When building the menu tree using _menu_link_translate(), function _menu_load_objects() is called too often or too few. Attached patch resolved the problem, not only the symptom: _menu_load_objects() should be called just-in-time.

The callstack in question is doing something like this:
menu_tree_all_data($menu_name)->menu_tree_check_access($tree, $node_links)->_menu_tree_check_access(&$tree)->_menu_link_translate($item)
--> _menu_check_access($item, $map);
---> menu_unserialize()
--> _menu_item_localize($item, $map, TRUE);
---> menu_unserialize()
Proposed patch moves _menu_load_objects() from _menu_check_access($item, $map) to menu_unserialize().
This way, the object is loaded only when it is needed.

The following issues all have different symptoms and solutions for the same problem.
#753064: _menu_link_translate() might avoid calling _menu_load_objects()

If you have menu items that refer to views (or any other expensive load_functions for that matter), this patch will dramatically increase your sites performance.

#1697570: _menu_load_objects() is not always called when building menu trees

#1973920: Too many calls to _menu_load_objects(), when building a menu with an enabled taxonomy_menu

... The whole vocabulary is read term-by-term by function _menu_load_objects(). In most cases, the menu can be generated without loading every term.


Viewing all articles
Browse latest Browse all 292273

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>