Hi! I'm using Drupal 6.22, Wysiwyg 6.x-2.4 and PHP 5.3.6.
Problem: when I attach a file when creating a node, I see the error: "warning: Parameter 2 to wysiwyg_form_alter () expected to be a reference, value given in / home / drupal / www / includes / common.inc on line 2892."
Perhaps this is due to the peculiarities of calling call_user_func_array () in PHP 5.3.
Sorry for my bad english> _ <

CommentFileSizeAuthor
bug.jpg161.92 KBAyumuKasuga

Comments

twod’s picture

Assigned: AyumuKasuga » Unassigned
Category: bug » support
Priority: Critical » Normal

This error most likely happens because another module is calling drupal_alter() incorrectly so $form_state gets cloned instead of referenced. drupal_alter() uses a key called __drupal_alter_by_ref to work around the issues with call_user_func_array(), but that won't help unless people actually put references in there.
As you can see in the error message, other modules also suffer because of this and there's nothing these modules can do about it. CCK had this problem a while back but it was fixed with the patch in #705512-32: drupal_alter('form'... called from content_add_more_js needs to pass $form_state as a reference.
I can not guess which module is creating this problem for you - at least not without a stack trace. I can only recommend that you make sure all modules are up-to-date and hope the calling module has fixed this.
If the problem is there, you can try inserting

print_r(debug_backtrace());

or, if you have devel.module installed,

dsm(debug_backtrace());

at the top of one of the functions mentioned in the errormessage. (wysiwyg_form_alter() is in wysiwyg.module). Then you'll have to dig through that backtrace until you find from where drupal_alter() is being called and search for or create a bug report for that module.

twod’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

memcinto’s picture

OK help me out here, if you would be so good. According to the backtrace, drupal_alter() is being called by drupal_prepare_form in includes/form.inc. However this call is formed correctly, so that can't be the problem.

Backtrace says:

[0]
function (String, 18 characters ) wysiwyg_form_alter | (Callback) wysiwyg_form_alter();
args (Array, 3 elements) 
[1]
file (String, 52 characters ) /.../includes/commo...
line (Integer) 2892
function (String, 20 characters ) call_user_func_array | (Callback) call_user_func_array();
args (Array, 2 elements) 
[2]
file (String, 50 characters ) /.../includes/form.inc
line (Integer) 551
function (String, 12 characters ) drupal_alter | (Callback) drupal_alter();
args (Array, 3 elements) 
[3]
file (String, 50 characters ) /.../includes/form.inc
line (Integer) 106
function (String, 19 characters ) drupal_prepare_form | (Callback) drupal_prepare_form();
args (Array, 3 elements) 
[4]
file (String, 60 characters ) /.../modules/node/n...
line (Integer) 14
function (String, 15 characters ) drupal_get_form | (Callback) drupal_get_form();
args (Array, 2 elements) 
[5]
function (String, 14 characters ) node_page_edit | (Callback) node_page_edit();
args (Array, 1 element) 
[6]
file (String, 50 characters ) /.../includes/menu.inc
line (Integer) 349
function (String, 20 characters ) call_user_func_array | (Callback) call_user_func_array();
args (Array, 2 elements) 
[7]
file (String, 42 characters ) /.../index.php
line (Integer) 17
function (String, 27 characters ) menu_execute_active_handler | (Callback) menu_execute_active_handler();
args (Array, 0 elements)

drupal_prepare_form says,

 // Normally, we would call drupal_alter($form_id, $form, $form_state).
  // However, drupal_alter() normally supports just one byref parameter. Using
  // the __drupal_alter_by_ref key, we can store any additional parameters
  // that need to be altered, and they'll be split out into additional params
  // for the hook_form_alter() implementations.
  // @todo: Remove this in Drupal 7.
  $data = &$form;
  $data['__drupal_alter_by_ref'] = array(&$form_state);
  drupal_alter('form_'. $form_id, $data);

  // __drupal_alter_by_ref is unset in the drupal_alter() function, we need
  // to repopulate it to ensure both calls get the data.
  $data['__drupal_alter_by_ref'] = array(&$form_state);
  drupal_alter('form', $data, $form_id);
AgaPe’s picture

In wysiwyg.module you have to change the function declaration

function wysiwyg_form_alter(&$form, &$form_state) {
to
function wysiwyg_form_alter(&$form, $form_state) {