Bug #80527 [Com]: Current directory deleted before shutdown_function - File functions affected

From: Date: Thu, 17 Dec 2020 14:52:34 +0000
Subject: Bug #80527 [Com]: Current directory deleted before shutdown_function - File functions affected
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231132@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 Comment by: heavy-traffic-website at yopmail dot com Reported by: heavy-traffic-website at yopmail dot com Summary: Current directory deleted before shutdown_function - File functions affected Status: Not a bug Type: Bug Package: *Directory/Filesystem functions Operating System: Debian 11 PHP Version: 8.0.0 Assigned To: cmb Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#231132) next »