PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » PEAR » PEAR » Bug #5162

array_pop() bug

Details

Submitted2005-08-20 23:40 UTC
Fromjoe at joestump dot net
StatusBogus
PackagePEAR
PHP Version5.1.0
OSIrrelevant
Roadmaps(Not assigned)

Comments

[2005-08-20 23:40 UTC] joe at joestump dot net

Description:
------------
On line 1078 in PEAR/PackageFile/Generator/v1.php there is a
line of code that looks something like this:

$min = array_pop(array_flip($min));

This throws errors in PHP 5.1RC1 because you can only pass
variables by reference. I changed it to assign the result of
array_flip($min) to a temporary variable and then array_pop()
that and it works fine. Attached is a patch.

This, btw, totally broke channels (and I would assume anything
else that uses this code.

Test script:
---------------
--- v1.php.old 2005-08-20 16:33:42.000000000 -0700
+++ v1.php 2005-08-20 16:33:26.000000000 -0700
@@ -1075,7 +1075,8 @@
}
if (count($min)) {
// get the highest minimum
- $min = array_pop(array_flip($min));
+ $flip = array_flip($min);
+ $min = array_pop($flip);
} else {
$min = false;
}

[2005-08-20 23:44 UTC] joe at joestump dot net

This might even be a PHP bug, I'm also getting the following
error in PEAR_ErrorStack:

Notice: Only variable references should be returned by
reference in PEAR/ErrorStack.php on line 272

I guess now that PHP passes everything by reference it's
causing some odd issues if you don't do $var = foo() and
then pass $var. Very odd. I would think PHP would handle
this on it's own.

[2005-08-20 23:50 UTC] joe at joestump dot net

BTW, the problem in PEAR_ErrorStack on line 272 was fixed
with:

$ret = ($GLOBALS['_PEAR_ERRORSTACK_SINGLETON']
[$package] = & new $stackClass($package, $msgCallback,
$contextCallback, $throwPEAR_Error));
return $ret;