When updating a D7 install from 7.4 to 7.7 I came across an infinite loop before the update process fully finished. An issue was created for Drupal Core while the problem was debugged.

I have since debugged the problem and found the cause to be down this module having a call to the menu_get_item() function in the hook_theme() implementation, this coupled with a l() call in font-your-face's hook_menu() caused the inifite loop.

The original core issue is #1232346: Easy to trigger multiple menu rebuilds per page (including infinite recursion) via menu_get_item() since 7.12 and the font-your-face issue is #1235880: Infinite recursion in D7

Comments

agoradesign’s picture

Here's the problematic function:

function custom_search_theme() {
  if (user_access('use custom search')) {

    $custom_search_theme_array = array(
      'custom_search_javascript' => array(
        'variables' => array(),
      ),
      'custom_search_sort_form' => array(
        'render element'  => 'form',
        'template' => 'custom_search-sort-form',
      ),
      'search_result' => array(
        'variables' => array('result' => NULL, 'module' => NULL),
        'file' => 'custom_search.pages.inc',
        'template' => 'custom_search-result',
      ),
      'search_results' => array(
        'variables' => array('results' => NULL, 'module' => NULL),
        'file' => 'custom_search.pages.inc',
        'template' => 'custom_search-results',
      ),
    );

    // Panels integration
    $search_results_page_callback = menu_get_item('search/node/%menu_tail');
    if ($search_results_page_callback['page_callback'] == 'page_manager_search_page') {
      unset($custom_search_theme_array['search_results'], $custom_search_theme_array['search_result']);
    }

    return $custom_search_theme_array;

  }
  else return array();
}

The call to menu_get_item() could be easily replaced with a database query and as a bonus, it would be more efficient to do so.

somanyfish’s picture

This bug cost me a bunch of time. I enabled Custom Search, then did a bunch of work. The infinite loop did not occur until I tried to enable another module. I initially thought that the other module was causing the problem, but it was only when I figured out that enabling any module at all caused the infinite loop that I thought to go back and see what was the last module I installed, namely Custom Search. I really hope you fix this so it doesn't bite someone else.

Thank you agoradesign for posting this issue.

jdanthinne’s picture

Priority: Normal » Major

Wow, sorry but I was on holiday this month and I've just come across this issue. Pretty nasty one!
Unfortunately, I can't reproduce this bug, so can you give me the list of all contrib modules enabled on your install?

somanyfish’s picture

Thanks for responding and sorry to make your return from vacation buggy!

Here's the contrib modules installed. Let me know if any other info would help.

 CCK                        Multiselect (multiselect)                                    Module  Enabled        7.x-1.x-dev    
 Chaos tool suite           Chaos tools (ctools)                                         Module  Enabled        7.x-1.x-dev    
 Context                    Context (context)                                            Module  Enabled        7.x-3.0-beta1  
 Context                    Context UI (context_ui)                                      Module  Enabled        7.x-3.0-beta1  
 Custom Search              Custom Search (custom_search)                                Module  Enabled        7.x-1.8        
 Date/Time                  Calendar (calendar)                                          Module  Enabled        7.x-3.x-dev    
 Date/Time                  Date (date)                                                  Module  Enabled        7.x-2.x-dev    
 Date/Time                  Date API (date_api)                                          Module  Enabled        7.x-2.x-dev    
 Date/Time                  Date Popup (date_popup)                                      Module  Enabled        7.x-2.x-dev    
 Date/Time                  Date Tools (date_tools)                                      Module  Enabled        7.x-2.x-dev    
 Date/Time                  Date Views (date_views)                                      Module  Enabled        7.x-2.x-dev    
 Development                Devel (devel)                                                Module  Enabled        7.x-1.2        
 Development                Devel node access (devel_node_access)                        Module  Enabled        7.x-1.2        
 Features                   Features (features)                                          Module  Enabled        7.x-1.0-beta3  
 Features                   Showcase (one column) (showcase_one_column)                  Module  Enabled                       
 Features                   Showcase (two column) (showcase_two_column)                  Module  Enabled                       
 Fields                     Conditional Fields (conditional_fields)                      Module  Enabled        7.x-3.x-dev    
 Fields                     Email (email)                                                Module  Enabled        7.x-1.0        
 Fields                     Field collection (field_collection)                          Module  Enabled        7.x-1.x-dev    
 Fields                     Field Permissions (field_permissions)                        Module  Enabled        7.x-1.0-alpha1 
 Fields                     Fieldgroup (field_group)                                     Module  Enabled        7.x-1.0        
 Fields                     Link (link)                                                  Module  Enabled        7.x-1.x-dev    
 Input filters              Image resize filter (image_resize_filter)                    Module  Enabled        7.x-1.13       
 Media                      IMCE (imce)                                                  Module  Enabled        7.x-1.4        
 Nodequeue                  Nodequeue (nodequeue)                                        Module  Enabled        7.x-2.x-dev    
 Nodequeue                  Nodequeue Service (nodequeue_service)                        Module  Enabled        7.x-2.x-dev    
 Other                      AddToAny (addtoany)                                          Module  Enabled        7.x-3.1        
 Other                      Backup and Migrate (backup_migrate)                          Module  Enabled        7.x-2.2        
 Other                      Better Formats (better_formats)                              Module  Enabled        7.x-1.x-dev    
 Other                      Disable messages (disable_messages)                          Module  Enabled        7.x-1.x-dev    
 Other                      Entity API (entity)                                          Module  Enabled        7.x-1.0-beta10 
 Other                      Entity tokens (entity_token)                                 Module  Enabled        7.x-1.0-beta10 
 Other                      Exclude node title (exclude_node_title)                      Module  Enabled        7.x-1.3        
 Other                      HTML Purifier (htmlpurifier)                                 Module  Enabled        7.x-2.x-dev    
 Other                      Image caption (image_caption)                                Module  Enabled        7.x-1.x-dev    
 Other                      Insert Block (insert_block)                                  Module  Enabled        7.x-1.x-dev    
 Other                      Menu Block (menu_block)                                      Module  Enabled        7.x-2.2        
 Other                      Menu breadcrumb (menu_breadcrumb)                            Module  Enabled        7.x-1.3        
 Other                      Node clone (clone)                                           Module  Enabled        7.x-1.x-dev    
 Other                      Nodeblock (nodeblock)                                        Module  Enabled        7.x-1.2        
 Other                      Pathauto (pathauto)                                          Module  Enabled        7.x-1.0-rc2    
 Other                      Token (token)                                                Module  Enabled        7.x-1.x-dev    
 Rules                      Rules (rules)                                                Module  Enabled        7.x-2.0-rc1    
 Rules                      Rules UI (rules_admin)                                       Module  Enabled        7.x-2.0-rc1    
 SEO                        Page Title (page_title)                                      Module  Enabled        7.x-2.5        
 Services                   Services (services)                                          Module  Enabled        7.x-3.x-dev    
 Taxonomy                   Taxonomy CSV import/export (taxonomy_csv)                    Module  Enabled        7.x-5.6        
 User interface             CKEditor (ckeditor)                                          Module  Enabled        7.x-1.2        
 Views                      Views (views)                                                Module  Enabled        7.x-3.x-dev    
 Views                      Views UI (views_ui)                                          Module  Enabled        7.x-3.x-dev    
 Webform                    Webform (webform)                                            Module  Enabled        7.x-3.12       
 Webform                    Webform Conditional (webform_conditional)                    Module  Enabled        7.x-1.x-dev    
jdanthinne’s picture

Status: Active » Needs review

Ok, I think I've found a way to kill this loop… and pushed it to DEV.
The patch is there : http://drupalcode.org/project/custom_search.git/patch/f1a1a7a

I've replaced

$search_results_page_callback = menu_get_item('search/node/%menu_tail');
if ($search_results_page_callback['page_callback'] == 'page_manager_search_page') {
  unset($custom_search_theme_array['search_results'], $custom_search_theme_array['search_result']);
}

by

$router_item = db_query_range('SELECT page_callback FROM {menu_router} WHERE path = :path', 0, 1, array(':path' => 'search/node/%'))->fetchAssoc();
if ($router_item['page_callback'] == 'page_manager_search_page') {
  unset($custom_search_theme_array['search_results'], $custom_search_theme_array['search_result']);
}

Hope it works for you.

somanyfish’s picture

Hmm...I don't see your updating code in the latest dev release.

jdanthinne’s picture

I've just pushed the code, so the DEV version should be available tomorrow…
that's why I've included the changes ;-)

somanyfish’s picture

The dev release fixed the problem for me, thank you.

jdanthinne’s picture

@mjpa @agoradesign : is it working for you as well? I need to release a new stable version quickly.

mjpa’s picture

Works fine for me.

jdanthinne’s picture

Status: Needs review » Fixed

Great!

agoradesign’s picture

Sorry for the late answer - I've overseen this...

Yes, for me it works too because the menu_get_item() call is gone now. But I cannot proof, if the if-condition still works as expected because my installation doesn't need this check for the page_callback

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

Adding font-your-face issue number