Fatal error: Maximum function nesting level of '999' reached, aborting!

Steps to reproduce:

  • Add a custom page in page manager
  • Give it a path and an argument. For example, gorram-bug/%uid
  • Assign it the context User edit form: User ID
  • Click through to the the content tab, add some content to your shiny new page. Perhaps, say, the user edit form.
  • Go visit gorram-bug/1
  • Cry forever

Last step optional.

From my amateur-ish debugging, I've found that ctools_user_edit_context() gets called, and somewhere down the line is called again in ctools_context_get_context_from_argument() on line 796 of ctools/context.inc, creating a recursion.

CommentFileSizeAuthor
#2 ctool-context-user-edit-2205841-2-D7.patch953 bytesgngn

Comments

geekyMoa’s picture

Issue summary: View changes
gngn’s picture

Status: Active » Needs review
Issue tags: +ctools, +Context
StatusFileSize
new953 bytes

We experienced the same problem since ctools 7.x-1.3 (7.x-1.4 too).

Problem occurs with user_forms - node_forms are OK.

There is an infinite loop starting with menu_get_item() to drupal_retrieve_form():

1	0.0007	637128	{main}( )	../index.php:0
2	0.0014	701568	drupal_bootstrap( )	../index.php:20
3	0.0706	2663328	_drupal_bootstrap_full( )	../bootstrap.inc:2212
4	0.2778	19343688	menu_set_custom_theme( )	../common.inc:5147
5	0.2778	19343768	menu_get_custom_theme( )	../menu.inc:1770
6	0.2792	19357816	menu_get_item( )	../menu.inc:1755
7	0.2883	19370648	_menu_translate( )	../menu.inc:472
8	0.2883	19371280	_menu_load_objects( )	../menu.inc:761
9	0.2883	19375560	call_user_func_array ( )	../menu.inc:590
10	0.2883	19376432	pm_arg_load( )	../menu.inc:0
11	0.3124	20498616	_pm_arg_load( )	../page_manager.module:979
12	0.5063	30244744	ctools_context_get_context_from_argument( )	../page.inc:548
13	0.5116	30279456	ctools_user_edit_context( )	../context.inc:796
14	0.6356	33191088	ctools_context_create( )	../user_edit.inc:46
15	0.6411	33296464	ctools_context_create_user_edit_form( )	../context.inc:600
16	0.6430	33564672	drupal_build_form( )	../user_edit_form.inc:82
17	0.6430	33568560	drupal_retrieve_form( )	../form.inc:339
18	0.6430	33569136	menu_get_item( )	../form.inc:733
... (and so on from line 6 until maximum nesting level is reached

(We changed the paths, so ../ is our drupal root)

We looked at the changes introduced in 7.x-1.3 and found something in function ctools_context_create_user_edit_form (file file ctools/plugins/contexts/user_edit_form.inc).
The static $created - test for allready-created - changed from a simple TRUE|FALSE to an array with categories.
It first checks if $created[$category] is set (and returns if set).
In the following lines it checks $category and sets a default:

  // Return previously created contexts, per category.
  static $created = array();
  if (!empty($created[$category])) {
    return $created[$category];
  }
  // If no category was specified, use the default 'account'.
  if (!$category) {
    $category = 'account';
  }

We think this should be the other way round:
1. Check $category (and set default)
2. Check if $created[$category] is set

  // If no category was specified, use the default 'account'.
  if (!$category) {
    $category = 'account';
  }
  // Return previously created contexts, per category.
  static $created = array();
  if (!empty($created[$category])) {
    return $created[$category];
  }

We'll add a patch against the current dev.
Since ctools/plugins/contexts/user_edit_form.inc is the same as in 7.x-1.3 and 7.x-1.4, the patch can be applied to these versions, too.

Since we do not exactly understand the way ctools and form.inc work together, we're not sure if this is correct in all cases - but it solved our problem.
So if someone with a deeper ctools knowledge could have a look...

thanks and greetings, gngn and uli

damienmckenna’s picture

Version: 7.x-1.4 » 7.x-1.x-dev
Issue tags: -ctools, -Context

ACF’s picture

Status: Needs review » Reviewed & tested by the community

This looks good to me, simple fix and I can confirm that this fixes the problem.

  • japerry committed 85c289d on 7.x-1.x authored by gngn
    Issue #2205841 by gngn: Context for user edit form creates infinite loop
    
japerry’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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