I have a clean setup of Drupal 6.19 on PHP 5.3.2 and after trying to attach a file to any node I see the following warnings in the attachment fieldset of the form.
* warning: Parameter 2 to date_form_alter() expected to be a reference, value given in /var/www/trunk/includes/common.inc on line 2883.
* warning: Parameter 2 to date_timezone_form_alter() expected to be a reference, value given in /var/www/trunk/includes/common.inc on line 2883.I have created a patch which removes the pointer from the $form_state argument because it does not appear to be updated and this eliminates those warning messages.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | date.952258.8.patch | 2.23 KB | Countzero |
| #8 | date.952258.8.patch | 2.29 KB | mvc |
| #7 | File attachment warnings frenzy.png | 109.35 KB | thomas1977 |
| #2 | date.952258.patch | 1.91 KB | mvc |
| date_form_alter.diff | 1.38 KB | tangent |
Comments
Comment #1
mvcI'm not sure I completely understand what's going on here. I realize that drupal_alter() does allow passing arguments by reference where needed, but afaict it isn't necessary here.
Here is the call stack:
So, $form_state is passed by reference to date_form_alter() which passes it by reference to date_content_display_form(). From here it gets passed by value to date_formatter_settings() and then _date_formatter_settings(). The first three functions seem to do nothing with this value except to pass it to the next function in the list, and _date_formatter_settings() doesn't even use this value.
Either $form_state is there for possible future use, or it's being used in some clever way I'm not immediately seeing because I am not wise in the ways of the Drupal form API. Assuming the first case this patch should be safe, but at minimum I think that for consistency it should also change date_content_display() to not call $form_state by reference either.
Comment #2
mvcrevised patch which changes date_content_display() as described above
Comment #3
physiotek commentedthanks a lot for the patch.
i had this error and it was very annoying.
Comment #4
haggins commentedsame here - patch working.
However, the problem seems to be elsewhere because passing $form_state as reference deliveres correct function signature according to FormsAPI.
Comment #5
tangent commented@mvc, good catch. Your patch works for me.
@haggins, this warning appears on a clean install of Drupal 6.20 on PHP 3.5.3 with no other contrib module installed than the date modules. If the problem is elsewhere then it's in drupal_alter(). As mvc said, regardless of where the problem is, if *_form_alter() does not need to modify $form_state then there is no reason to use it as a reference. Removing the & will resolve the warning whether $form_state is passed as a reference or not.
Comment #6
haggins commentedAs I get this warnings on a whole bunch of modules that implement hook_form_alter() there seems to be something wrong in drupal core. I will try 6.20 later (currently using 6.19).
edit: updating core to 6.20 doesn't help
Comment #7
thomas1977 commentedSame here. The issue is probably not related to Date (not sure). I get a whole bunch of the warnings whenever I try to attach a file to a node - including warnings related to Date. See attached screenshot. BTW: using Drupal 6.20
Comment #8
mvcUpdated patch for 6.x-2.7
Comment #9
chey commentedHaving the same issue.
PHP 5.3.3
Drupal 6.20
Is the patch in #8 going to show up in a stable release anytime soon?
Comment #10
mvc@chey your help is needed with that -- first the patch needs to be reviewed! please try the patch, and whether it works for you or not, report your experiences here. when it's been tested and shown to work, the maintainer will know it's okay to add.
see http://drupal.org/patch/review if you've never done this before.
Comment #11
Countzero commentedThe patch doesn't apply to 2.7, I think because the paths are wrong like in
The 'patched' part shouldn't be there I guess. Corrected version attached. Applies and makes errors disappear.
Comment #12
choster commentedMarking as duplicate:
#747680: PHP 5.3 warning on date_form_alter()
#1078450: PHP 5.3 issue with date_timezone_form_alter function
#1078446: PHP 5.3 issue with date_form_alter function
This is a problem with many modules; see also http://drupal.org/node/710892 .
Comment #13
jackalope commentedThe patch in #11 worked well for me.
Comment #14
jmwhitco commentedPatch in #11 worked for me. I no longer get the two date related errors when uploading a file. Running D6.21 with PHP 5.32.
Comment #15
mvcsetting to RTBC based on multiple positive reviews
Comment #16
monotaga commentedAre you sure this isn't related to #925580: Upload throws warnings on PHP 5.3?
Comment #17
arlinsandbulte commentedI think this was fixed here:
#925580: Upload throws warnings on PHP 5.3