I think I see a coding error in content_profile_register.module
If I'm right, then it could be the cause of alot of problems.

at line 157:

  // Add in the new form elements into $form.
  $form += array('#field_info' => array());
  $form['#field_info'] += $node_form['#field_info'];
  $form += $form_add;

When += is used on arrays, only the UNIQUE keys (and their values) are copied over.

Using my debugger to step through the code, I can see the values of $form before and after that "$form += $form_add;" line.
Both arrays are large, so here's just one duplicate array element for example:

BEFORE:

"$form['#submit']"	Array [1]	
- 0	logintoboggan_user_register_submit	

"$form_add['#submit']"	Array [3]	
- 0	menu_node_form_submit	
- 1	_flexifield_node_form_submit	
- 2	auto_nodetitle_node_form_submit	

AFTER:

"$form['#submit']"	Array [1]	
- 0	logintoboggan_user_register_submit	

"$form_add['#submit']"	Array [3]	
- 0	menu_node_form_submit	
- 1	_flexifield_node_form_submit	
- 2	auto_nodetitle_node_form_submit	

In other words, none of that info was copied into your form.
See below (in the full version of this message) for an example of the full contents of those arrays, and you'll see that this could be a significant source of problems.
Hope it helps.


$form  Array [53]	
--> user_registration_help	Array [2]	
--> account	Array [7]	
--> #uid	<Uninitialized>	
--> xmlsitemap	Array [6]	
--> timezone	Array [3]	
--> submit	Array [3]	
--> #validate	Array [3]	
--> #parameters	Array [2]	
--> #build_id	form-13131529f7b5f6cf83aaf927a5f0b055	
--> #type	form	
--> #programmed	false	
--> form_build_id	Array [4]	
--> form_id	Array [3]	
--> #id	user-register	
--> #description	<Uninitialized>	
--> #attributes	Array [1]	
--> #required	false	
--> #tree	false	
--> #parents	Array [0]	
--> #method	post	
--> #action	/user/register	
--> #submit	Array [2]	
--> terms_of_use	Array [4]	
--> captcha	Array [4]	
--> #after_build	Array [2]	
--> pass	Array [1]	
--> #content_profile_registration_use_types	Array [2]	
--> #field_info	Array [37]	
--> nid	Array [2]	
--> vid	Array [2]	
--> created	Array [2]	
--> type	Array [2]	
--> changed	Array [2]	
--> title	Array [7]	
--> #node	stdClass	
--> revision_information	Array [8]	
--> comment_settings	Array [7]	
--> #cache	false	
--> menu	Array [20]	
--> path	Array [9]	
--> field_pr_intro_partnering	Array [15]	
--> field_pr_kind_partner	Array [15]	
--> field_pr_i_mu	Array [15]	
--> field_pr_i_ff	Array [23]	
--> field_pr_i_end_mu	Array [15]	
--> field_pr_o_mu	Array [15]	
--> field_pr_o_ff	Array [23]	
--> field_pr_o_end_mu	Array [15]	
--> field_pr_closediv_partnering_mu	Array [15]	
--> #pre_render	Array [2]	
--> #content_extra_fields	Array [8]	
--> revision_moderation	Array [2]	
--> #content_profile_weights	Array [22]	

$form_add  Array [58]	
--> #id	node-form	
--> nid	Array [2]	
--> vid	Array [2]	
--> created	Array [2]	
--> type	Array [2]	
--> changed	Array [2]	
--> title	Array [7]	
--> #node	stdClass	
--> revision_information	Array [8]	
--> #validate	Array [1]	
--> #parameters	Array [3]	
--> #type	form	
--> #programmed	false	
--> form_id	Array [3]	
--> #description	<Uninitialized>	
--> #attributes	Array [1]	
--> #required	false	
--> #tree	false	
--> #parents	Array [0]	
--> #method	post	
--> #action	/projects/climbingpartner/trunk/user/register	
--> comment_settings	Array [7]	
--> #cache	false	
--> menu	Array [20]	
--> #submit	Array [2]	
--> path	Array [9]	
--> #field_info	Array [28]	
--> field_pr_intro_personal	Array [15]	
--> field_pr_headline	Array [12]	
--> field_pr_residence	Array [12]	
--> field_pr_dob	Array [12]	
--> field_pr_sex	Array [15]	
--> field_pr_interested_in	Array [15]	
--> field_pr_interested_in_2	Array [15]	
--> field_pr_marital_status	Array [15]	
--> field_pr_height	Array [15]	
--> field_pr_weight	Array [15]	
--> field_pr_languages	Array [15]	
--> field_pr_ethnicity	Array [15]	
--> field_pr_religion	Array [15]	
--> field_pr_education	Array [15]	
--> field_pr_occupation	Array [15]	
--> field_pr_income_level	Array [15]	
--> field_pr_smoking	Array [15]	
--> field_pr_drinking	Array [15]	
--> field_pr_drugs	Array [15]	
--> field_pr_kids	Array [15]	
--> field_pr_licence	Array [15]	
--> field_pr_car	Array [15]	
--> field_pr_first_aid	Array [15]	
--> field_pr_hobies	Array [15]	
--> field_pr_closediv_personal_mu	Array [15]	
--> field_pr_residence_geo	Array [18]	
--> #pre_render	Array [1]	
--> #content_extra_fields	Array [8]	
--> #after_build	Array [2]	
--> revision_moderation	Array [2]	
--> xmlsitemap	Array [6]	

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

johnnybgoode’s picture

-- UPDATE --
this patch will not work, it appears to clobber some value in the original form causing the form not to submit properly.

as a temporary fix I am using the following to apply all necessary #submit and #validate functions:

$handler_types = array('#submit', '#validate');
foreach($handler_types as $h) {
  foreach($form_add[$h] as $callback) {
    $form[$h][] = $callback;
  }
}

This only gives you all of your submit and validate functions, all other data is lost as highlighted in the original bug report so a better fix is needed.

PS. I can't remove the patch, or I would, so just don't use it!
-- /UPDATE --

-- original --
proposed fix: use array_merge instead of or in addition to +=

attached:
proposed patch
-- /original --

MarcElbichon’s picture

This prevents duplicate callbacks

$handler_types = array('#submit', '#validate',"#after_build");
  foreach($handler_types as $h) {
    foreach($form_add[$h] as $callback) {
      if (! in_array($callback, $form[$h])) {
        $form[$h][] = $callback;
      }
    } 
  }