Download & Extend

Warning: call-time pass-by-reference has been deprecated

Project:Link Image Field
Version:6.x-1.0-beta1
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

When I enable the module I immediately get this warning (see attached jpg).
After deleting the "&" before "$form_state" on line 134 in linkimagefield_widget.inc the warning no longer appears.
Is this the right solution?
If so, could you implement it in the next version because I suppose this scares off a lot of people to use this module.
For the rest, this module works just as I expected it to work.

AttachmentSize
pass-by-reference.jpg148.78 KB

Comments

#1

good catch - I have work to do today...I'll try to upload a fix later. Removing the & is exactly what you need to do. Looks like I just copied the function prototype for imagefield_widget_process.

#2

Warning: Call-time pass-by-reference has been deprecated in /home/content/s/w/2/sw2010/html/beta3/sites/all/modules/linkimagefield/linkimagefield_widget.inc on line 134

this is the error message i get..and immediately removed the module...
i'll review your fix above..but , could really use this module if it worked..
thanks

#3

function linkimagefield_widget_process($element, $edit, $form_state, $form) {
  $file = $element['#value'];
  $element = imagefield_widget_process($element, $edit, $form_state, $form);

  // add some help text, telling user the URL field will be viewable after the file is supplied
  $element['upload']['#description'] = t('Once an Image is uploaded, you will ba able to supply a URL for the link.') . '<br />' . $element['upload']['#description'];
  
  $field = content_fields($element['#field_name'], $element['#type_name']);
  $element['#theme'] = 'linkimagefield_widget_item';
 
  $element['data']['url'] = array(
    '#title' => t('URL'),
    '#type' => 'textfield',
    '#default_value' => $file['data']['url'] ? $file['data']['url'] : $field['widget']['url'],
    '#description' => t('This URL will be loaded when the image is clicked'),
    '#maxlength' => 255,
  );

i modified lines 132 and 134 to remove the & as noted above..and so far, no error message..

I've been able to use the link image widget w.out problem after the fix above.. thanks alot.. very useful.. and the error message was/is offputting..

eggonbeagle..

#4

Status:active» fixed

actually, you should only remove the & from line 134. That is the call-time pass-by-reference. I'm uploading the fix now, though.

#5

hmmm

should i add the ampersand back on to line 132..after the fact? its running fine, seemingly..
thanks for the response..

#6

the function prototype on line 132 allows the $form_state variable to be modified in this function and the changes will stick after this function returns. As long as one doesn't make a change to $form_state, it shouldn't matter. This is a standard method for handling the form's state in Drupal's Form API, i.e., developers expect to receive a modifiable reference in these types of functions.

Line 134, however, is not a function protoype but rather an actual function call and PHP no longer allows explicitly passing a reference into a function. This & is there because I copied the function prototype from the imagefield_widget_process function and neglected to remove that &.

#7

thanks for that explanation.
i've added it back in on line 132..

thank you again.

#8

Status:fixed» closed (fixed)

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

#9

I am using ver 6.x-1.x-dev and I got the same error message on line 89 of linkimagefield_widget.inc

According to thsi thread, this issue was fixed.

Or could it be a php version issue? I am using php 5.2.11

Thanks,

#10

Status:closed (fixed)» active