I was getting a WSOD and eventually tracked it down to a unnecessarily memory greedy db_select():

Line 383 in features_menu_link_load() in features.menu.inc currently:

  // If link_path was changed on an existing link, we need to find it by
  // searching for link_title.
  else if (isset($clean_title)) {
    $links = db_select('menu_links')
    ->fields('menu_links', array('menu_name', 'mlid', 'plid', 'link_path', 'router_path', 'link_title', 'options', 'module', 'hidden', 'external', 'has_children', 'expanded', 'weight'))
    ->condition('menu_name', $menu_name)
    ->execute()
    ->fetchAllAssoc('mlid');

should be changed to only load the needed fields:

  // If link_path was changed on an existing link, we need to find it by
  // searching for link_title.
  else if (isset($clean_title)) {
    $links = db_select('menu_links')
    ->fields('menu_links', array('menu_name', 'mlid'))
    ->condition('menu_name', $menu_name)
    ->execute()
    ->fetchAllAssoc('mlid');

Admittedly this matched 802 rows in our case (this is lots and lots of menus each with lots of items and lots of sub items), but I find WSODs take hours to track down the cause since every time you put a break point, if it disappears down the white hole of a WSOD before it reaches it, you have to start again, so fixing this would be great.

I see a similar thing on line 358 which also be given the slimming treatment:

  $links = db_select('menu_links')
     ->fields('menu_links', array('menu_name', 'mlid', 'plid', 'link_path', 'router_path', 'link_title', 'options', 'module', 'hidden', 'external', 'has_children', 'expanded', 'weight', 'customized'))
     ->condition('menu_name', $menu_name)
     ->condition('link_path', $link_path)
     ->execute()
    ->fetchAllAssoc('mlid');

Features is a great module. Thanks!

CommentFileSizeAuthor
#4 2300321-menu_links-4.patch2.86 KBpcambra
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hefox’s picture

Title: db_select('menu_links') loads unnecessary fields causing WSOD » db_select('menu_links') loads unnecessary fields is memory hoggy

Should likely enable error reporting to screen on development sites

drupalshrek’s picture

This is a development site with error reporting to screen enabled. Sometimes though, WSOD errors still don't show, and debugging at the coal face is the only way to go.

hefox’s picture

Title: db_select('menu_links') loads unnecessary fields is memory hoggy » db_select('menu_links') loads unnecessary fields, is memory hoggy
Version: 7.x-2.0 » 7.x-2.x-dev

I think there may have been a reason to load those fields, but not looking at the code atm

pcambra’s picture

Status: Active » Needs review
FileSize
2.86 KB

I'm having a similar issue, haven't got to the bottom of the issue but I think this would help a little.