Bug #80527 [Opn->Nab]: Current directory deleted before shutdown_function - File functions affected
| From: | cmb@php.net | Date: | Thu, 17 Dec 2020 14:34:22 +0000 |
| Subject: | Bug #80527 [Opn->Nab]: Current directory deleted before shutdown_function - File functions affected | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-231131@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80527&edit=1
ID: 80527
Updated by: cmb@php.net
Reported by: heavy-traffic-website at yopmail dot com
Summary: Current directory deleted before shutdown_function -
File functions affected
-Status: Open
+Status: Not a bug
Type: Bug
-Package: *General Issues
+Package: *Directory/Filesystem functions
Operating System: Debian 11
PHP Version: 8.0.0
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
See <https://www.php.net/manual/en/function.register-shutdown-function.php#refsect1-function.register-shutdown-function-notes>.
Previous Comments:
------------------------------------------------------------------------
[2020-12-17 14:30:44] heavy-traffic-website at yopmail dot com
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 this bug report at https://bugs.php.net/bug.php?id=80527&edit=1