| Project: | Date |
| Version: | 7.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
I get the following warnings when I import a local database to my Dreamhost server. The code at these lines is a bit more "involved" than I can quickly decipher:
Warning: Call-time pass-by-reference has been deprecated in /path/to/sites/all/modules/date/date/date.module on line 657
Warning: Call-time pass-by-reference has been deprecated in /path/to/sites/all/modules/date/date/date.module on line 665
Warning: Call-time pass-by-reference has been deprecated in /path/to/sites/all/modules/date/date/date.module on line 673
Warnings appear on all pages on Dreamhost, but not on any pages on my local server. The two sites use the same version of the date module (HEAD) and Drupal core (HEAD or alpha3, same result) and the same database (dumped from localhost and uploaded to the server).
Dreamhost: PHP Version 5.2.10
Localhost: PHP Version 5.2.10-2ubuntu6.4
Display errors are turned on for both servers.
I'm a bit stumped, but thought I'd report in any case. Screenshot of warnings attached. Errors are written to the screen before the rest of the page is loaded.
| Attachment | Size | Status | Test result | Operations |
|---|---|---|---|---|
| warnings-passbyref.png | 20.86 KB | Ignored: Check issue status. | None | None |
Comments
#1
This is indeed a server setting. Dreamhost is using the more restrictive option. Altering my local server to use the restrictive setting results in the error being displayed. It doesn't seem as though Dreamhost allows me to reset allow_call_time_pass_reference. Fixing the code is the better option.
Locally:
; Whether to enable the ability to force arguments to be passed by reference
; at function call time. This method is deprecated and is likely to be
; unsupported in future versions of PHP/Zend. The encouraged method of
; specifying which arguments should be passed by reference is in the function
; declaration. You're encouraged to try and turn this option Off and make
; sure your scripts work properly with it in order to ensure they will work
; with future versions of the language (you will receive a warning each time
; you use this feature, and the argument will be passed by value instead of by
; reference).
allow_call_time_pass_reference = On
on Dreamhost:
allow_call_time_pass_reference = Off
On line 474 of the D6 module there was no $items (and therefore no & and no problem):
http://drupalcode.org/viewvc/drupal/contributions/modules/date/date/date...
http://api.drupal.org/api/function/hook_field_update/7 lists an & before $items, maybe this was just copy/pasted?
chx took a look at
http://drupalcode.org/viewvc/drupal/contributions/modules/date/date/date...
and said, "function _date_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) { <= that's fine, the function takes $items by reference so yeah submit that patch"
So I've attached a patch which removes & from being sent to the function from date.module.
#2
Patch attached. Needs review.
#3
Yeah, that patch helped. Here's a re-roll against HEAD, for offsets.
Also a new(?) function date_field_presave() repeated the error, so this fixes that one too.
#4
The attached patch fixes additional instances of pass-by-reference which were creating errors as follows:
Deprecated function: Call-time pass-by-reference has been deprecated in drupal_load() (line 941 of /path/to-drupal/drupal-7.x-dev/includes/bootstrap.inc).
#5
Fixed, thanks so much!
#6
Automatically closed -- issue fixed for 2 weeks with no activity.