Req #80527 [Opn->Dup]: Current directory deleted before shutdown_function - File functions affected
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: Duplicate
Type: Feature/Change Request
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:
Well, actually a duplicate of bug #40661.
Previous Comments:
------------------------------------------------------------------------
[2020-12-17 14:54:52] heavy-traffic-website at yopmail dot com
Not a Bug ? -> Feature
------------------------------------------------------------------------
[2020-12-17 14:52:34] heavy-traffic-website at yopmail dot com
I only use PHP-FPM with Haproxy with FCGI, not Apache.
I understand there is a little notice that inform it can change during the shutdown function...
but... is this normal for our use / need ? Probably not.
Why don't you are able to restore the CWD during the shutdown function ? Since i am able to
write a one-line fix ; it should be evaluated the feature to not change the CWD during the shutdown
function.
------------------------------------------------------------------------
[2020-12-17 14:34:22] cmb@php.net
See <https://www.php.net/manual/en/function.register-shutdown-function.php#refsect1-function.register-shutdown-function-notes>.
------------------------------------------------------------------------
[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
Thread (6 messages)