Fatal error: Maximum execution time of 1000 seconds exceeded in /var/www/dev.aboutgiving.net/public_html/sites/all/modules/menu_clone/menu_clone.module on line 100

While trying to clone a menu.

Sounds like it is stuck in this loop:


..

 while(!empty($result)) {
    $new_name = substr('clone' . $i . '-' . $menu['menu_name'], 0, MENU_MAX_MENU_NAME_LENGTH_UI);
    $result = db_result(db_query($sql, 'menu-' . $new_name));
  }

..

I'm not sure why hook_load is used (menu_clone_load)? Isn't this function called every time node_load is called? I am not sure what that has to do with a menu clone process, but maybe I am missing something..

Jason

CommentFileSizeAuthor
#3 bug infinite loop.patch457 bytesadrianpintilie

Comments

jason.fisher’s picture

This only happens on one specific menu that I have..

jason.fisher’s picture

I think it has something to do with MENU_MAX_MENU_NAME_LENGTH_UI + 'menu-' being greater than the largest possible menu machinekey?

If I use "MENU_MAX_MENU_NAME_LENGTH_UI-1" -- i.e. change this portion of the code to (left my debug deadwood):


  $new_name = substr('clone-' . $menu['menu_name'], 0, MENU_MAX_MENU_NAME_LENGTH_UI-1);
  $sql = "SELECT menu_name FROM {menu_custom} WHERE menu_name = '%s'";
  $result = db_result(db_query($sql, 'menu-' . $new_name));
  $i = 1;
  while(!empty($result)) {
//    print $idebug++; //  . ': ' . $result . '<br>';
//    if ($idebug > 100) exit();
    $new_name = substr('clone' . $i . '-' . $menu['menu_name'], 0, MENU_MAX_MENU_NAME_LENGTH_UI-1);
//    print strlen('menu-' . $new_name) . '<br>';
    $result = db_result(db_query($sql, 'menu-' . $new_name));
  }

Then everything seems to work fine. You are doing a substr() for a specific length and then prefixing it with 'menu-' .. could that be it?

adrianpintilie’s picture

Priority: Major » Normal
StatusFileSize
new457 bytes

the code is incorrect here. The loop occurs when you try to clone a menu that you cloned before and you used the generated naming convention.

you need

$i++;

in the loop. I have attached a patch.

malc0mn’s picture

Assigned: Unassigned » malc0mn
Status: Active » Fixed

Whoa, what a stupid one! Thanks adrianpintilie!

Patch committed and beta4 release is available.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.