I attempted to upgrade from 5.x-2.0-beta9 to beta10 and got this message. Currently running on php 4.4.8

Parse error: syntax error, unexpected '=', expecting ')' in /var/www/vhosts//httpdocs/sites/all/modules/subscriptions/subscriptions_mail.module on line 165

Please let me know if you need more info.

Comments

gustav’s picture

Status: Active » Needs review
StatusFileSize
new20.75 KB

It appears that that version of PHP does not like default values for variables that are passed by reference. The attached simple patch (modifying only two lines) should solve the problem.

salvis’s picture

Status: Needs review » Needs work

I must admit that I had some doubts whether a NULL default value would work for a reference parameter, but it works on my PHP 5.1.6. There's some discussion about this on http://ch2.php.net/manual/en/language.references.pass.php, but it's not quite conclusive...

@gustav: Your "simple patch" is huge and tries to replace the entire file. Do you maybe have a problem with the newlines? We actually have a problem with them in that file, too: some are LF-only and some are CR/LF. This will be fixed in the next beta.

To expose the problem: we have a function that takes a reference parameter, and I'd like to pass a NULL to it to tell it to do something special. My solution:

function f(&$parm = NULL) {}
f();

works with PHP5 but not with PHP4.

gustav's proposed fix is

function f(&$parm) {}
f(NULL);

but passing a constant rather than a variable isn't supposed to work at all!

Right now I'm on the edge between

function f(&$parm) {}
@f();

and

function f(&$parm) {}
f($this_is_an_unused_dummy_variable = NULL);

I hate introducing dummy variables...

reikiman’s picture

I noticed the same issue. The immediate symptom is fixed by removing the default values. However that's obviously not 100% accurate. I also removed all the ^M's (as a hated windozism) so if I tried to supply a patch it would be just as large.

salvis’s picture

Status: Needs work » Needs review
StatusFileSize
new969 bytes

This should work (the @ version doesn't).

beginner’s picture

I had the same parse error problem.
The patch in #4 works for me.
+1.

Also +1 on removing the ^M's.

salvis’s picture

Version: 5.x-2.0-beta10 » 5.x-2.0-beta11
Status: Needs review » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

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