Parse error: parse error, unexpected '&', expecting T_VARIABLE or '$'

kenorb - October 24, 2008 - 12:03
Project:Cache browser
Version:6.x-1.1
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

I've got followed error when I'm going to admin/build/cache_browser:

Parse error: parse error, unexpected '&', expecting T_VARIABLE or '$' in /cache_browser/cache_browser.pages.inc on line 463

Probably this reference method is not supported by PHP 4.x

Temporary I've changed:

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

to:
        foreach ($data as $key => $value) {

But I don't know which functionality I'll lost.

#1

kenorb - October 24, 2008 - 12:38
Status:active» needs review

Line 463 and the same in line 504

#2

markus_petrux - October 24, 2008 - 13:26

Hi,

The problem is I've been using a PHP5 thing here.

Your code above may cause to break the process when browsing an array or object with a lot of nested levels, such as things cached by views.

Could you please try this instead:

foreach ($data as $key => $value) {
  $value = &$data[$key];  // This & should work on PHP4.
  ...

This would replace the following in lines 463 and 504.

foreach ($data as $key => &$value) { // <-- This & here requires PHP5.
  ...

#3

markus_petrux - October 26, 2008 - 02:53
Status:needs review» fixed

Nah, it was not so easy...

I just released 6.x-1.2 with a fix for this, and a few more things.

Feel free to reopen if needs to be.

#4

markus_petrux - November 2, 2008 - 16:31
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.