Recently I stumled upon the Drupal 5.3 compatabilty issue, specifically with ImageCache Actions module. But there are several other modules affected.

The bug regarding User Import Framework is that watchdog gets errors upon import saying:

Parameter 1 to uif_batch_import_users_process() expected to be a reference, value given in <drupal root>/includes/batch.inc on line 193.

Taking into account the comment over at the ImageCache Actions thread would suggest that my patch is harmless but fixes the problem. Since the call by reference never worked in the first place...

CommentFileSizeAuthor
uif-admin-inc.patch460 bytesMichael Zetterberg fd. Lopez

Comments

dwightaspinwall’s picture

Thanks - this seems like the right thing to do but how do I pass $form_state by reference (which is what I intend)?

Michael Zetterberg fd. Lopez’s picture

Since you are using the Batch API it does not seem possible at the time. In _batch_process (batch.inc) the following code does the invocation:

if ((list($function, $args) = reset($current_set['operations'])) && function_exists($function)) {
  // Build the 'context' array, execute the function call,
  // and retrieve the user message.
  $batch_context = array('sandbox' => &$current_set['sandbox'], 'results' => &$current_set['results'], 'finished' => &$finished, 'message' => &$task_message);
  // Process the current operation.
  call_user_func_array($function, array_merge($args, array(&$batch_context)));
}

To pass by reference you would need to alter that call_user_func_array invocation I think, making the result of the array_merge into a variable that is sent along. Like so:

$args = array_merge($args, array(&$batch_context));
call_user_func_array($function, $args);

Either this is by design or you could possible open an issue discussing the possibility to call by reference in Batch API.

Out of curiosity, why do you want $form_state by reference? It isn't used in a "by reference manner" anywhere in your code as far as I can tell.

dwightaspinwall’s picture

Status: Needs review » Closed (fixed)

Frankly, I don't understand how the batch code works, or why the reference isn't getting passed along. But regardless, as you say, I don't modify $form_state; the only reason I'm passing it by reference is to save memory, which is probably not a good justification. So, I'll pass $form_state by value and commit this.

Thanks Michael!

Michael Zetterberg fd. Lopez’s picture

Great!