I'm getting this error message on node/add forms where the I'm using the openlayers_geocoder cck widget:

warning: Parameter 1 to openlayers_cck_widget() expected to be a reference, value given in /.../includes/module.inc on line 462.

Line 462 in module.inc refers to the module_invoke() function, which ol_geocoder is using to invoke the openlayers_cck_widget functions. This is a PHP 5.3 compatability issue. The function signature for hook_widget requires the $form and $form_state parameters to be passed by reference. Unfortunately module_invoke() does not pass arguments by reference, and as a result PHP 5.3 is causing a warning message to be displayed on the node/add form.

As a quick fix, the function signature from:
function openlayers_cck_widget(&$form, &$form_state, $field, $items, $delta = 0)
to:
function openlayers_cck_widget($form, $form_state, $field, $items, $delta = 0).

I've been scratching my head trying to come up with a better way to fix this. I'm very new at this. My first thought is to include the code from the openlayers_cck.module file and call the widget functions directly. So far I haven't been successful at doing that, and I'm not sure its even legitimate.

Comments

ccardea’s picture

Status: Active » Needs review
StatusFileSize
new1.44 KB

Note that an issue has been raised in core regarding the inability of the module_invoke function to pass parameters by reference. The issue is complicated because PHP has stated that call-time passing of parameters by reference is deprecated. I've attached a patch that provides a solution until the issue can be resolved regarding call-time passing of parameters by reference.

dasjo’s picture

+++ openlayers_geocoder.module	2011-02-27 13:43:51.314098001 -0500
@@ -186,9 +200,14 @@ function openlayers_geocoder_widget(&$fo
+  $args[] = $delta;  ¶

just noting that those lines end with unneccessary blanks

Powered by Dreditor.

ccardea’s picture

I'm glad somebody noticed.

xamanu’s picture

here comes the patch without the spaces at the end of the line, that dasjo mentioned :-)

It actually works for me. Thanks!

rahulbot’s picture

Worked great for me - thanks!

barraponto’s picture

Version: 6.x-2.0-alpha5 » 6.x-2.x-dev

Works for me as well.

brunorios1’s picture

worked for me too.

thanks!

barraponto’s picture

Status: Needs review » Reviewed & tested by the community

changing status

steinmb’s picture

If RTBC, any chance of getting this commited? What core issue number is the description text referring to?

steinmb’s picture

Priority: Normal » Major

Bumping

aerozeppelin’s picture

Thank you!
#1 Worked for me.

barraponto’s picture

Priority: Major » Normal

@steinmb i want this committed too, but it is not a major bug. it is just a warning.

steinmb’s picture

Yeah, I know. I raised the priority more as an desperate act to get the developers attention :) 5 months as RTBC..

barraponto’s picture

@steinmb if you have the time, please step up as comantainer. just create an issue and let's see what the mantainer says.

leramulina’s picture

Priority: Normal » Critical

I have
Drupal 6.24
CCK 6.x-3.0-alpha3
Openlayers 6.x-2.0-beta1
Geocoder 6.x-2.0-alpha5

And it did not help me

steinmb’s picture

Priority: Critical » Normal

Warnings are never critical. That aside, did you apply the patch in #4, and what PHP version are you getting this warning on?

leramulina’s picture

Yes, I applied.
I have version PHP: 5.3.8

leramulina’s picture

I get this:

Fatal error: Cannot redeclare ol_module_invoke() (previously declared in C:\xampp\htdocs\expat\sites\all\modules\openlayers_geocoder\openlayers_geocoder.module:188) in C:\xampp\htdocs\expat\sites\all\modules\openlayers_geocoder\openlayers_geocoder.module on line 207

steinmb’s picture

Reviewed and tested on

* Drupal 6.26
* Openlayers Geocoder 6.x.2.x-dev
* PHP 5.3.5

Rerolling #4. The workaround still works. perhaps not the most elegant way of removing those warnings in PHP 5.3 but as long as it works.

steinmb’s picture

Removed one trailing white space found in #19.

steinmb’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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