Bug #80527 [NEW]: Current directory deleted before shutdown_function - File functions affected
| From: | heavy-traffic-website at yopmail dot com | Date: | Thu, 17 Dec 2020 14:30:44 +0000 |
| Subject: | Bug #80527 [NEW]: Current directory deleted before shutdown_function - File functions affected | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-231130@lists.php.net to get a copy of this message | ||
From: heavy-traffic-website at yopmail dot com
Operating system: Debian 11
PHP version: 8.0.0
Package: *General Issues
Bug Type: Bug
Bug description:Current directory deleted before shutdown_function - File functions affected
Description:
------------
Files functions doesn't work with relative paths since the current
working directory is deleted during the "exit" line. Is this a bug or a
feature ? :-)
Test script:
---------------
function debug_cwd(int $i)
{
syslog(LOG_DEBUG, "getcwd [$i] -> " . getcwd());
}
function shutdown()
{
debug_cwd(4);
chdir('/var/www/website');
debug_cwd(5);
}
chdir('/var/www/website')
debug_cwd(1);
register_shutdown_function('shutdown');
debug_cwd(2);
fastcgi_finish_request();
debug_cwd(3);
exit;
debug_cwd(6); // will not be displayed
Expected result:
----------------
$> tail /var/log/syslog
Dec 17 15:09:43 hosting php: getcwd [1] -> /var/www/website
Dec 17 15:09:43 hosting php: getcwd [2] -> /var/www/website
Dec 17 15:09:43 hosting php: getcwd [3] -> /var/www/website
Dec 17 15:09:43 hosting php: getcwd [4] -> /var/www/website
Dec 17 15:09:43 hosting php: getcwd [5] -> /var/www/website
Actual result:
--------------
$> tail /var/log/syslog
Dec 17 15:09:43 hosting php: getcwd [1] -> /var/www/website
Dec 17 15:09:43 hosting php: getcwd [2] -> /var/www/website
Dec 17 15:09:43 hosting php: getcwd [3] -> /var/www/website
Dec 17 15:09:43 hosting php: getcwd [4] -> /
Dec 17 15:09:43 hosting php: getcwd [5] -> /var/www/website
--
Edit bug report at https://bugs.php.net/bug.php?id=80527&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80527&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80527&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80527&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80527&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80527&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80527&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80527&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80527&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80527&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80527&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80527&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80527&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80527&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80527&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80527&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80527&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80527&r=mysqlcfg