3 replies [Last post]
chombium's picture
Offline
Joined: 09/29/2008
Juice: 20
Was this information Helpful?

I'm building e-commerce web page with multiple sellers and buyers. After enabling the marketplace mp_product module I've noticed the following warning:

Warning: Call-time pass-by-reference has been deprecated; If you would like to pass it by reference, modify the declaration of module_invoke_all(). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file in .../drupal/modules/ubercart/ubercart_marketplace/mp_products/mp_products.module on line 219

Diving in to the code I've seen that there is a function call in which the variable is called by reference.

line 219 from mp_products.module is:

module_invoke_all('list_product', &$node);

This is happening because the php.ini variable "allow_call_time_pass_reference = Off". That's the recommended value so I didn't want to change it.

After a little googling I've seen that this is a bad PHP practice.
Here is a link from sitepoint.com describing the issue and presenting a solution:
http://www.sitepoint.com/article/object-oriented-php/7/

Instead of calling the function with the variable passed by reference, the function should be written to accept variables by reference.

I wanted to create a patch but I couldn't find the declaration of module_invoke_all. I'm new to drupal development Sad

My environment is:
Apache 2.2.8
PHP 5.2.6
MySQL 5.0.51b
Drupal 5.10
Ubercart 1.4

How can I fix this issue? I don't want to set allow_call_time_pass_reference = On

CHEERS, Jovan

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4110
Re: Problems with ubercart marketplace module

You can edit that code and just remove the ampersand from the function args. I believe this is a PHP5 issue, in PHP4 it might've been the preferred method.

<?php
module_invoke_all
('list_product', $node);
?>

--
Help directly fund development: Donate via PayPal!

chombium's picture
Offline
Joined: 09/29/2008
Juice: 20
Re: Re: Problems with ubercart marketplace module

Thanks, I soleved the issue as you suggested.

torgosPizza wrote:

You can edit that code and just remove the ampersand from the function args. I believe this is a PHP5 issue, in PHP4 it might've been the preferred method.

You are right, it's a PHP5 issue. In PHP5, by default, all the variable are passed by reference.

If the development of this module is done in PHP4 how can we make it compatible/friendly to PHP5?
Maybe the code should be checked for PHP5 incompatibilities.

Turgrid's picture
Offline
Joined: 03/05/2008
Juice: 109
Re: Re: Re: Problems with ubercart marketplace module

Ubercart Marketplace was developed for PHP5. The issue you experienced was a basically a typo and will be removed in the next version. You should find that the module works great in a PHP5 environment (and that is the recommended version).