Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I've received a PHP Maximum Execution Timeout when trying to edit a node. The timeout is 300 sec (5 min).
The error has occured at various points but most commonly on line 1220 of token.module (7.x-1.5) which is inside the token_menu_link_load_all_parents function:
function token_menu_link_load_all_parents($mlid) {
$cache = &drupal_static(__FUNCTION__, array());
if (!is_numeric($mlid)) {
return array();
}
if (!isset($cache[$mlid])) {
$cache[$mlid] = array();
$plid = db_query("SELECT plid FROM {menu_links} WHERE mlid = :mlid", array(':mlid' => $mlid)\
)->fetchField();
while ($plid && $parent = token_menu_link_load($plid)) {
$cache[$mlid] = array($plid => $parent['title']) + $cache[$mlid]; // Line #1220
$plid = $parent['plid'];
}
}
return $cache[$mlid];
}
This site has a very large and deeply nested Main Menu. I'm unsure at this time what is causing the failure. Clearing caches has not affected performance on this issue.
Comment | File | Size | Author |
---|---|---|---|
#10 | 2327361-php-timeout-token-1.patch | 614 bytes | filsterjisah |
|
Comments
Comment #1
nerdcore CreditAttribution: nerdcore commentedI discovered that there was an infinite loop in that function being caused by a rogue entry in the menu_links table which was listed as parent of itself (mlid=plid). I've corrected the erroneous field in the DB and the site is functional again. Not sure how that happened.
Comment #2
JesseDP CreditAttribution: JesseDP commentedI think token should add this extra check.
Patch included.
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous as a volunteer commented#2 patch is the life saver. Thanks JesseDP
Comment #4
wroxbox CreditAttribution: wroxbox commentedPatch included
Comment #9
Dave ReidThis needs a parenthesis around the $parent variable assignment, or to move the $plid != $mlid before the $parent assignment (the latter is preferred).
Comment #10
filsterjisah CreditAttribution: filsterjisah for District09 commentedI've added an updated patch with changes suggested by Dave Reid.
Comment #11
anouThanks to filsterjisah. Patch works great.
Comment #12
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedThe 3 year old patch in #10 to token.module applied cleanly to the latest token 7.x-1.x-dev and works great for me as well.
Comment #14
Dave ReidCommited #10 to 7.x-1.x!