After installing the latest version of 6.x-1.x-dev (that was published on 2009-Mar-15) my site went offline since all requests resulted in the following error message:
PHP Parse error: syntax error, unexpected '&', expecting T_VARIABLE or '$' in /var/www/sites/all/modules/path_redirect/path_redirect.module on line 280

The culprit is the following line (occuring twice in the mentioned version of path_redirect.module):

foreach ($where as $key => &$value) {

The &$value syntax is a PHP5 feature and I'm using PHP4.
Removing the "&" (thus having just $value in these lines) fixes the problem.
I've attached a patch made against the mentioned release.

CommentFileSizeAuthor
path_redirect.patch644 bytesmüzso

Comments

dave reid’s picture

Well, crap. This is why I hate PHP4. Patch will not work because the value needs to be modified.

dave reid’s picture

Status: Needs review » Fixed

Thanks for the report. Fixed using

   foreach ($where as $key => $value) {
     if (is_string($key)) {
       $args[] = $value;
       $where[$key] = $key .' = '. (is_numeric($value) ? '%d' : "'%s'");
müzso’s picture

Yes. I've noticed it too after having tested the fix on two Drupal sites.
Interestingly even my patch seemed to work on one site :-o (I don't know why, don't ask me :-) ) and it failed on another one. That's one of the reasons that I only spotted the problem a bit later (and the other one is that I've been out of practise with PHP for the last year or so).

dave reid’s picture

Title: syntax error, unexpected '&', expecting T_VARIABLE or '$' in sites/all/modules/path_redirect/path_redirect.module on line 280 » PHP4 compatibility - foreach with references
Issue tags: +PHP 4, +I hate PHP 4

Yeah, not sure why it worked. :) I found a couple places in some of my other modules where I did this. Thanks again for the report. :)

Status: Fixed » Closed (fixed)
Issue tags: -PHP 4, -I hate PHP 4

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

Issue tags: +, +