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

Bug #6050 PEAR version displayed as 'Array' instead of version number
Submitted: 2005-11-23 15:08 UTC
From: atex Assigned: farell
Status: Closed Package: PEAR_Info
PHP Version: 5.1.2 OS: Mandriva Linux 10.2/2.6.11
Roadmaps: 1.7.0RC1    
Subscription  


 [2005-11-23 15:08 UTC] atex
Description: ------------ I copied the test/pear_info.php file to my webroot and tested it with PEAR 1.4.2 and it worked great. I then noticed that PEAR was out of date and update PEAR to 1.4.5 using 'pear update PEAR'. I then went back to the pear_info.php page and noticed that at the top of the page, it did not say 'PEAR 1.4.5' like it should have, but rather 'PEAR Array'. So, apparently between 1.4.2 and 1.4.5 there was a difference with how PEAR's version structure is stored (as an Array instead of a string). I am currently using PEAR_Info 1.6.0 Test script: --------------- The test script is 'pear_info.php' that comes with PEAR_Info. The error is that the $pear variable returned on line 54 of Info.php is different in PEAR 1.4.5 than in previous PEAR versions. On line 89 of Info.php, it assumed $pear['version'] is a string. Here is the patch that fixed the problem for me: --- Info.php 2005-01-03 12:33:43.000000000 -0500 +++ Info.php.new 2005-11-23 10:02:44.000000000 -0500 @@ -86,7 +86,10 @@ <table> <tr class="h"> <td> - <a href="http://pear.php.net/"><img src="<?php echo $_SERVER['PHP_SELF'];?>?pear_image=true" alt="PEAR Logo" /></a><h1 class="p">PEAR <?php echo $pear['version']; ?></h1> + <a href="http://pear.php.net/"><img src="<?php echo $_SERVER['PHP_SELF'];?>?pear_image=true" alt="PEAR Logo" /></a><h1 class="p">PEAR <?php +if (is_array($pear['version'])) { echo $pear['version']['release']; } +else { echo $pear['version']; } +?></h1> </td> </tr> </table> Expected result: ---------------- The top header should report 'PEAR <version>' where <version> is the version of PEAR. Actual result: -------------- With PEAR 1.4.5 'PEAR Array' is displayed.

Comments

 [2005-11-23 16:20 UTC] atex
I made an updated patch that (hopefully) fixed all the problems when upgrading to 1.4.5. The problem appears to be in the version of the package.xml file that is used. This patch adds several functions and replaces references to values that have changed location between 1.0 and 2.0 and returns the correct value. The functions test the 'xsdversion' parameter of variables returned from a packageInfo registry call. Please disregard the previously posted patch. The patch is as follows: --- Info.php.version 2005-01-03 12:33:43.000000000 -0500 +++ Info.php 2005-11-23 11:09:42.000000000 -0500 @@ -86,7 +86,7 @@ <table> <tr class="h"> <td> - <a href="http://pear.php.net/"><img src="<?php echo $_SERV\ ER['PHP_SELF'];?>?pear_image=true" alt="PEAR Logo" /></a><h1 class="p">PEAR <?p\ hp echo $pear['version']; ?></h1> + <a href="http://pear.php.net/"><img src="<?php echo $_SERV\ ER['PHP_SELF'];?>?pear_image=true" alt="PEAR Logo" /></a><h1 class="p">PEAR <?p\ hp echo $this->getPackageVersion($pear); ?></h1> </td> </tr> </table> @@ -150,7 +150,7 @@ $packages = ''; foreach ($available as $name) { $installed = $this->reg->packageInfo($name); - if (strlen($installed['package']) > 1) { + if (strlen($this->getPackageName($installed)) > 1) { if (!isset($old_index)) { $old_index = ''; } @@ -161,7 +161,7 @@ $this->index[] = $current_index; } $packages .= ' - <h2><a name="pkg_' .trim($installed['package']). '">' .trim($installed\ ['package']). '</a></h2> + <h2><a name="pkg_' .trim($this->getPackageName($installed)). '">' .tri\ m($this->getPackageName($installed)). '</a></h2> <table> <tr class="v"> <td class="e"> @@ -176,7 +176,7 @@ Version </td> <td> - ' .trim($installed['version']). ' + ' .trim($this->getPackageVersion($installed)). ' </td> </tr> <tr class="v"> @@ -192,24 +192,25 @@ State </td> <td> - ' .trim($installed['release_state']). ' + ' .trim($this->getPackageState($installed)). ' </td> </tr> <tr class="v"> <td class="e"> Information </td> + <td> </td> </tr>'; if ($latest != FALSE) { - if (isset($latest[$installed['package']])) { - if (version_compare($latest[$installed['package']]['ver\ sion'],$installed['version'],'>')) { + if (isset($latest[$this->getPackageName($installed)])) { + if (version_compare($this->getPackageVersion($latest[$t\ his->getPackageName($installed)]),$this->getPackageVersion($installed),'>')) { $packages .= '<tr class="v"> <td class="e"> Latest Version </td> <td> - <a href="http://pear.php.net/get/' .trim($insta\ lled['package']). '">' .$latest[$installed['package']]['version'] . '</a> - ('. $latest[$installed['package']]['state']. ') + <a href="http://pear.php.net/get/' .trim($this-\ >getPackageVersion($installed)). '">' .$this->getPackageVersion($latest[$this->\ getPackageName($installed)]) . '</a> + ('. $latest[$this->getPackageName($installed)][\ 'state']. ') </td> </tr>'; } @@ -331,11 +332,11 @@ echo '<tr class="h"><td>Package</td><td>Maintainers</td></tr>'; foreach ($available as $name) { $installed = $this->reg->packageInfo($name); - if (strlen($installed['package']) > 1) { + if (strlen($this->getPackageName($installed)) > 1) { ?> <tr> <td class="e"> - <a href="http://pear.php.net/<?php echo trim(strtolowe\ r($installed['package'])); ?>"><?php echo trim($installed['package']); ?></a> + <a href="http://pear.php.net/<?php echo trim(strtolowe\ r($this->getPackageName($installed))); ?>"><?php echo trim($this->getPackageNam\ e($installed)); ?></a> </td> <td class="v"> @@ -408,7 +409,33 @@ return $reg->packageExists($package_name); } else { $installed = $reg->packageInfo($package_name); - return version_compare($version, $installed['version'], '<='); + return version_compare($version, $this->getPackageVersion($install\ ed), '<='); + } + } + + function getPackageVersion($pkgInfo) { + if ($pkgInfo['xsdversion'] < 2) { + return $pkgInfo['version']; + } + else { + return $pkgInfo['version']['release']; + } + } + + function getPackageName($pkgInfo) { + if ($pkgInfo['xsdversion'] < 2) { + return $pkgInfo['package']; + } + else { + return $pkgInfo['name']; + } + } + function getPackageState($pkgInfo) { + if ($pkgInfo['xsdversion'] < 2) { + return $pkgInfo['release_state']; + } + else { + return $pkgInfo['stability']['release']; } } }
 [2005-11-24 02:04 UTC] davey
Is it possible for you to send me this patch via e-mail, to davey@php.net ? Thanks a tonne! I've been meaning to look in to this for weeks :) - Davey
 [2006-02-25 23:46 UTC] fa
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.
 [2006-03-22 16:14 UTC] atex
I downloaded 1.6.1 and this bug seems to have resurfaced (i.e. packages with package2.xml files are not displayed or have incomplete listings). I checked the CVS version and it seems to have the same bugs as 1.6.1. I have re-worked the original patch and it is available at the following URL: http://molior.mcs.suffolk.edu/patches/PEAR_Info-v2.patch.bz2 This patch adds 3 methods to the PEAR_Info class (getPackageVersion, getPackageName, getPackageState) that account for the differences in v1 and v2 package file XML structures. I have also patched the rest of the code to use these methods instead of the $installed['package'], $installed['version'], and $installed['release_state'] array references that cause the problem. In addition, I added isset checks to the methods since they will not work inline while using these methods. Let me know if you have any questions.
 [2006-11-26 23:08 UTC] cweiske (Christian Weiske)
I can confirm that package.xml v2 files are not displayed.
 [2007-06-28 17:26 UTC] farell (Laurent Laville)
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. This bug is fixed with request 7741 solution (new rewrite to make it PEAR 1.3.x, 1.4.x and 1.5.x compatible.