Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.10.15

Bug #16108 PEAR_PackageFile_Generator_v2 PHP4 parse error when running upgrade-all
Submitted: 2009-04-16 05:21 UTC
From: mickoz Assigned: dufuz
Status: Closed Package: PEAR (version 1.8.1)
PHP Version: 4.4.4 OS: Linux
Roadmaps: 1.9.0    
Subscription  


 [2009-04-16 05:21 UTC] mickoz (Michael Muryn)
Description: ------------ After running: # pear upgrade-all I got this parse error on PHP4: Parse error: syntax error, unexpected '&', expecting T_VARIABLE or '$' in /usr/local/lib/php/PEAR/PackageFile/Generator/v2.php on line 380 The problem seems to be with the &$c in the foreach in this code of the file: foreach ($arr['changelog']['release'] as &$c) { if (isset($c['notes'])) { // This trims out the indenting, needs fixing $c['notes'] = "\n" . trim($c['notes']) . "\n"; } } Without having analyzing what you are trying to do but only reading the syntax... either we do not want to put a "&" there or if we really want to use it as reference, we might want to use this technique to iterate an array by reference that is compatible in PHP4 and PHP5: foreach (array_keys(arr['changelog']['release']) as $c_key) { $c =& $arr['changelog']['release'][$c_key]; ... } For an unknown reason, I have not noticed this error on all my pear installation. And this error prevented me to upgrade from PEAR 1.7.2 to 1.8.1. The only difference with this PEAR installation is that it is an user-specific PEAR installation upgraded by the system PEAR (the system PEAR is up to date to 1.8.1, but not this user installation, so that is probably a new problem with PEAR > 1.7.2). From http://www.php.net/foreach it states that this feature (foreach by reference) is available since PHP5: As of PHP 5, you can easily modify array's elements by preceding $value with &. This will assign reference instead of copying the value.

Comments

 [2009-04-18 03:09 UTC] dufuz (Helgi Þormar Þorbjörnsson)
-Status: Open +Status: Closed -Assigned To: +Assigned To: dufuz
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.
 [2009-08-08 10:35 UTC] ashnazg (Chuck Burgess)
For historical/searchable reasons, I'll mention that I also see this behavior in PEAR 1.8.1 using PHP 4.4.9 when running "pear package" to build a TGZ file.