php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74823 getcwd() incorrect output in register_shutdown_function()
Submitted: 2017-06-28 09:57 UTC Modified: 2017-06-28 18:42 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: william at jwlchina dot cn Assigned:
Status: Not a bug Package: Directory function related
PHP Version: 7.0.20 OS: ubuntu14.04
Private report: No CVE-ID: None
 [2017-06-28 09:57 UTC] william at jwlchina dot cn
Description:
------------
Server: docker ubuntu14.04 
php-fpm version:7.0.15 and 7.0.20
Nginx: 1.4.6

getcwd() incorrect output in register_shutdown_function()

getcwd() returns wrong directory in register_shutdown_function(), only happens when using php-fpm or cgi. Bug not found in cli mode. 

Test script:
---------------
<?php

echo "Expected:" . getcwd() . "<br>";

register_shutdown_function(function () {
    echo "In shutdown function:" . getcwd() . "<br>";
});


// Output:
// Expected:/var/www/html/test
// In shutdown function:/

Expected result:
----------------
Expected:/var/www/html/test
In shutdown function:/var/www/html/test

Actual result:
--------------
Expected:/var/www/html/test
In shutdown function:/

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-06-28 18:42 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2017-06-28 18:42 UTC] requinix@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

http://php.net/manual/en/function.register-shutdown-function.php
> Note:
> Working directory of the script can change inside the shutdown function under
> some web servers, e.g. Apache.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Nov 28 09:01:23 2020 UTC