Posted by tbenice on September 28, 2010 at 7:29pm
30 followers
| Project: | Drupal core |
| Version: | 6.x-dev |
| Component: | upload.module |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
| Issue tags: | PHP 5.3 |
Issue Summary
As discussed thoroughly in http://drupal.org/node/705512, php5.3 does not allow passing array() into a function expecting a reference.
Behavior is:
upload a file and when the next upload field is produced there is a Warning:
"warning: Parameter 2 to [module]_form_alter() expected to be a reference, value given in [.]/common.inc on line 2883."
I'm not near a system to create a patch (sorry).
My solution was to copy the CCK fix:
upload.module line 629:
--drupal_alter('form', $form, array(), 'upload_js');
++ $form_state = array();
++ $data = $form;
++ $data['__drupal_alter_by_ref'] = array(&$form_state);
++ drupal_alter('form', $data, 'upload_js');
works great for me.
Comments
#1
Fix for upload module similar to the one from #705512: drupal_alter('form'... called from content_add_more_js needs to pass $form_state as a reference.
#2
The last submitted patch, upload-drupal_alter_parameter_by_reference.patch, failed testing.
#3
The same patch for latest CVS core version.
#4
The last submitted patch, upload-drupal_alter_parameter_by_reference_2.patch, failed testing.
#5
Trying to change version to see if this way the patch is at least applied during test.
#6
#3: upload-drupal_alter_parameter_by_reference_2.patch queued for re-testing.
#7
The last submitted patch, upload-drupal_alter_parameter_by_reference_2.patch, failed testing.
#8
#3: upload-drupal_alter_parameter_by_reference_2.patch queued for re-testing.
Not sure why it's failing: applies cleanly and works.
#9
The last submitted patch, upload-drupal_alter_parameter_by_reference_2.patch, failed testing.
#10
#3: upload-drupal_alter_parameter_by_reference_2.patch queued for re-testing.
#11
Yes, so strange the patch looks good and can solved issues like:
# warning: Parameter 2 to *****_form_alter() expected to be a reference, value given in C:\Arquivos de Programas\wamp\www\drupal-6.15\includes\common.inc on line 2829.
#12
The last submitted patch, upload-drupal_alter_parameter_by_reference_2.patch, failed testing.
#13
I simply modified the file upload.module like tbenice suggested. OK, not a good idea to modify the core, but it works well for me. Thanks!
#14
New patch attached. This one sends in an empty form_state array, which is what (I think) the intent was of the original code.
#15
Updated the title and tagged with PHP 5.3.
#16
Just to get the latest line number (from 6.20) in here where folks will see the problem upon uploading a file:
* warning: Parameter 2 to date_form_alter() expected to be a reference, value given in /var/www/html/includes/common.inc on line 2892.
#17
#14 Worked for me. Fixed ad / ad_image module use on php 5.3 which relies on upload.
#18
This looks good.
I can't quite see the point of
$data = &$form;as opposed to using$formdirectly, but it does no harm, and regardless this is clearly the appropriate solution to the problem, as the__drupal_alter_by_refkey is the official API for passing extra arguments by reference when callingdrupal_alter().#19
this patch worked for me :)
#20
Worked for me too. Can we get this committed?
#21
#22
How do you apply this patch? Obviously I'm a noob but I can't find info on this kind of file off Google to "do it yourself".
#23
Jewish_Doctor: Start reading here: http://drupal.org/patch
#24
Same issue. Subscribing.
#25
Patch worked for me. Commit it, please )
#26
There's no need to do these strange tricks. It should be enough to do $empty_form_state = array(); and pass that instead of array() directly no?
#27
The patch is exactly what http://api.drupal.org/api/drupal/includes--form.inc/function/drupal_prep... does when it already has an $form_state variable defined:
<?php$data = &$form;
$data['__drupal_alter_by_ref'] = array(&$form_state);
drupal_alter('form_' . $form_id, $data);
?>
#28
Dave Reid pointed out that we do need to do this, and it's copied from drupal_prepare_form(), I'd apparently not seen that pattern before.
#29
This is correct. Ideally, we'd add a @see drupal_prepare_form(), but I don't really care about the inline docs in older releases.
#30
This patch silently breaks uploading for me (i.e. no errors, but nothing gets uploaded either).
#31
The patch from #14 is working so far for me.
As much as I love hacking core (and fatally wounding young felines in the process), any chance we can get this committed?
#32
Yes, let's get this committed. Unfortunately, a lot of contrib modules have used the
<?phpdrupal_alter('form', $form, array(), $form_id);
?>
#33
Committed this, thanks for testing.
#34
I am still using #14 solution successfully.
From #33 I understand this has been committed. Does that mean that new downloads of core include this change? Or, what am I supposed to do to have the change included when creating a new OA site?
#35
@lyd: the next bugfix Drupal release (either 6.23 or 6.24) will include the fix. In the meantime it is in the development version of Drupal 6 already.
#36
I applied the patch and the files are being uploaded. However they are not displaying in the "File Attachments" list. The uploader runs and resets and the file gets put in the files folder.
#37
Patch @ #14 worked perfect on Atrium 1.0 install.
#38
Automatically closed -- issue fixed for 2 weeks with no activity.
#39
The patch in #14 didn't work for me. any suggestions?
Open Atrium 1.0
Drupal 6.22
I get these warning messages..
warning: Parameter 2 to notifications_team_form_alter() expected to be a reference, value given in /www/openatrium/docs/includes/common.inc on line 2892.warning: Parameter 2 to purl_form_alter() expected to be a reference, value given in /www/openatrium/docs/includes/common.inc on line 2892.
warning: Parameter 2 to spaces_form_alter() expected to be a reference, value given in /www/openatrium/docs/includes/common.inc on line 2892.
warning: Parameter 2 to atrium_form_alter() expected to be a reference, value given in /www/openatrium/docs/includes/common.inc on line 2892.
warning: Parameter 2 to atrium_book_form_alter() expected to be a reference, value given in /www/openatrium/docs/includes/common.inc on line 2892.
warning: Parameter 2 to casetracker_form_alter() expected to be a reference, value given in /www/openatrium/docs/includes/common.inc on line 2892.
warning: Parameter 2 to date_form_alter() expected to be a reference, value given in /www/openatrium/docs/includes/common.inc on line 2892.
warning: Parameter 2 to date_timezone_form_alter() expected to be a reference, value given in /www/openatrium/docs/includes/common.inc on line 2892.
warning: Parameter 2 to og_form_alter() expected to be a reference, value given in /www/openatrium/docs/includes/common.inc on line 2892.
warning: Parameter 2 to fivestar_form_alter() expected to be a reference, value given in /www/openatrium/docs/includes/common.inc on line 2892.
warning: Parameter 2 to ideation_form_alter() expected to be a reference, value given in /www/openatrium/docs/includes/common.inc on line 2892.
warning: Parameter 2 to wysiwyg_form_alter() expected to be a reference, value given in /www/openatrium/docs/includes/common.inc on line 2892.
warning: Parameter 2 to og_access_form_alter() expected to be a reference, value given in /www/openatrium/docs/includes/common.inc on line 2892.
warning: Parameter 2 to notifications_content_form_alter() expected to be a reference, value given in /www/openatrium/docs/includes/common.inc on line 2892.
#40
I have the same issue. Using Drupal 6
#41
I have the same issue as TechNikh @ #39
Any clues would be nice:-)
EDIT: I applied the patch to upload.module for Open Atrium and it works for me:-)
#42
@Ludwig #41
I am applying the patch in #14 manually to upload.module file in /www/openatrium/docs/modules/upload
I still see the warning messages. do you know where I am doing wrong?
#43
editing includes/common.inc as per http://drupal.org/node/710892#comment-3884210 , fixed the warning in my case
#44
Applying the patch in #14 fixed my problem. I also patched common.inc as mentioned in #43 to fix yet another PHP 5.3 error message, and that also worked.
#45
Patch in #14 worked for me - at least for this error. (I also had to apply a patch to common.inc, as described http://drupal.org/node/710892#comment-3884210, to fix another problem.)