From:             ant at specialops dot ath dot cx
Operating system: Linux 2.6.30 (gentoo)
PHP version:      5.3.0
PHP Bug Type:     Scripting Engine problem
Bug description:  Current directory in shutdown function leaks between requests

Description:
------------
In 5.3.0 one of my scripts stopped working due to the behaviour documented
at the bottom of the register_shutdown_function page.

The actual problem is that if I change the directory in the shutdown
function, that change persists across requests and can end up in completely
unrelated scripts' shutdown function calls.

Reproduce code:
---------------
<?php
echo "Script A\n";
function test() {
    echo getcwd() . "\n";
    if ( file_exists('file.inc') ) {
        include 'file.inc';
    }
}
register_shutdown_function('test');
?>

<?php
echo "Script B\n";
function change() {
    chdir('/tmp/');
    file_put_contents('file.inc', '<?php echo "something nasty\n"; ?>');
}
register_shutdown_function('change');
?>

Expected result:
----------------
Script A
/var/www/localhost/htdocs/
Script B
Script A
/var/www/localhost/htdocs/

Actual result:
--------------
Script A
/var/www/localhost/htdocs/
Script B
Script A
/tmp
something nasty

-- 
Edit bug report at http://bugs.php.net/?id=49753&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=49753&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=49753&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=49753&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=49753&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=49753&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=49753&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=49753&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=49753&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=49753&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=49753&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=49753&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=49753&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=49753&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=49753&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=49753&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=49753&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=49753&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=49753&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=49753&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=49753&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=49753&r=mysqlcfg

Reply via email to