#32786 [NEW]: global on unset var messes up extract( , EXTR_SKIP)
| From: | mcrusch at svm dot vetmed dot wisc dot edu | Date: | Wed, 20 Apr 2005 21:52:09 +0000 |
| Subject: | #32786 [NEW]: global on unset var messes up extract( , EXTR_SKIP) | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-77973@lists.php.net to get a copy of this message | ||
From: mcrusch at svm dot vetmed dot wisc dot edu
Operating system: Windows XP SP2
PHP version: 4CVS-2005-04-20 (stable)
PHP Bug Type: Variables related
Bug description: global on unset var messes up extract( , EXTR_SKIP)
Description:
------------
I called extract($array, EXTR_SKIP) in the global scope on an array and
one of the variables did not extract, even thought it was not set.
I traced the problem to a function call in which there was a global
statement involving the variable. This seems to have created the variable
in the global scope, but isset($var) (in the global scope) and
isset($GLOBALS["var"]) both return false. So, the variable is not set,
but it will not extract.
The only way to detect that it is in the symbol table is to do a
print_r($GLOBALS), which allows you to visually see that it is there, but
there is no way to programmatically detect it (other than capturing the
output of print_r and parsing it--ugly!)
Problem also occurs on a SuSE 9.3 Linux box (Linux kernel v.
2.6.5-7.147-smp) running PHP 4.3.9
Reproduce code:
---------------
$arrayOfStuff = array("stuff" => "valueOfStuff");
echo isset($stuff).", ".isset($GLOBALS["stuff"]).", $stuff\n";
// Commenting out the globalStuff() call produces the
// expected result
globalStuff();
extract($arrayOfStuff, EXTR_SKIP);
echo isset($stuff).", ".isset($GLOBALS["stuff"]).", $stuff\n";
function globalStuff() {
global $stuff;
}
Expected result:
----------------
, ,
1, 1, valueOfStuff
Actual result:
--------------
, ,
, ,
--
Edit bug report at http://bugs.php.net/?id=32786&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32786&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=32786&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=32786&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=32786&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=32786&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=32786&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=32786&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=32786&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=32786&r=support
Expected behavior: http://bugs.php.net/fix.php?id=32786&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=32786&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=32786&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=32786&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32786&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=32786&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=32786&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=32786&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=32786&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=32786&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=32786&r=mysqlcfg