This issue isn't caused by token, however this bit of code is where things got stuck. If a menu item has itself as a parent token_menu_link_get_parents_all then you will get stuck in an infinite loop. I've rolled a patch (that I haven't tested) that should identify this case and log and error, returning the tree as far as it could get.
function token_menu_link_get_parents_all($mlid) {
$parents = array();
while (!empty($mlid)) {
$link = token_menu_link_load($mlid);
if ($mlid == $link['plid']) { // Recursion catch
watchdog('error', 'Menu item %mlid has itself as a parent', array('%mlid' => $mlid));
return $parents;
}
array_unshift($parents, $link);
$mlid = $link['plid'];
}
return $parents;
}
Without spending a lot of time testing this it I don't feel confident submitting it as a proper patch, but it's a start on some discussions - is this better than a hard limit on the number of loops? Should the return value be different?
Cheers
Comments
Comment #1
osopolarI also got this infinite loop, where $mlid == $link['plid']. I haven't yet found how it was possible that a menu item references itself as parent, but somehow it was.
We use a lot of custom code for menu settings together with the hs_menu submodule of hierarchical_select, which could have caused this situation.
@serenecloud: Did you find the reason why it was possible to save a menu item with itself as a parent? Your workaround works well, but I definitely prefer to find the root cause of this problem.
Comment #2
osopolarComment #3
bluegeek9 commented