From: dmitry dot bezer at enterra-inc dot com
Operating system: Windows XP
PHP version: 4.3.10
PHP Bug Type: Scripting Engine problem
Bug description: strange behaviour of array_keys function
Description:
------------
After setting up PHP4.3.10 my application stoped working with error
message saying about error in one of PEAR files.
After looking into code that caused error I figured out a very strange
thing: the array_keys function gets as parameter a valid array but
returns NULL. I tried to reproduce the bug without using PEAR files but
didn't succeed. So I will describe the issue using PEAR code.
File: PEAR/DB/dataobject.php (version 1.7.2) (DB_DataObject PEAR package)
P.S. I have no Zend debuger/optimizer/.... or any 3rd party extensions
installed
php -v result:
C:\wwwroot\bug>php -v
PHP 4.3.10 (cgi-fcgi) (built: Dec 14 2004 17:47:59)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
Reproduce code:
---------------
795 if (is_object($from)) {
796 $table = $from->__table;
797 $from = array_keys($from->table());
798 }
$from->table() returns a valid array , but $from after assignment becomes
NULL.
If we modidfy the code in the following way:
795 if (is_object($from)) {
796 $table = $from->__table;
$tmp = $from->table();
var_dump($tmp);
797 $from = array_keys($tmp);
var_dump($from)
die('theend');
798 }
the result will be:
array(2) {
["id"]=>
int(129)
["name"]=>
int(2)
}
NULL
theend
moreover if we modify the code in another way:
if (is_object($from)) {
$table = $from->__table;
$tmp = $from->table();
$from = null;
$from = array_keys($tmp);
}
PHP crashes and Windows offers to send a report to Bill Gates :)
--
Edit bug report at http://bugs.php.net/?id=31265&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31265&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=31265&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=31265&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=31265&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=31265&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=31265&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=31265&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=31265&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=31265&r=support
Expected behavior: http://bugs.php.net/fix.php?id=31265&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=31265&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=31265&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=31265&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31265&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=31265&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=31265&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=31265&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=31265&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=31265&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=31265&r=mysqlcfg