php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #40661 cwd is reset when shutdown handler runs
Submitted: 2007-02-27 14:44 UTC Modified: 2021-10-11 13:52 UTC
Votes:4
Avg. Score:4.2 ± 0.8
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:2 (66.7%)
From: derick@php.net Assigned:
Status: Open Package: Apache related
PHP Version: 5.2.5 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2007-02-27 14:44 UTC] derick@php.net
Description:
------------
When this script is run with the Apache1 sapi the second CWD is reset to /.

This is an issue for both php 4.4.4 and php 5.2.1rc3.

Reproduce code:
---------------
<?php
echo "CWD = ", getcwd(), "\n";

function handler()
{
    echo "CWD = ", getcwd(), "\n";
    echo dirname( __FILE__ ), "\n";
}

register_shutdown_function( 'handler' );
?>



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-02-27 15:00 UTC] derick@php.net
I disagree, there is no reason why PHP can't reset the CWD to the correct directory when a shutdown handler is run. That is what I would expect to happen.
 [2007-07-11 12:35 UTC] jani@php.net
Making sure this doesn't slip through the cracks..also found in PHP 5.2
 [2011-04-08 21:22 UTC] jani@php.net
-Package: Feature/Change Request +Package: Apache related
 [2021-10-11 13:52 UTC] cmb@php.net
> Making sure this doesn't slip through the cracks..

Didn't work. :)

While it shouldn't be hard to restore the CWD during the shutdown
handler, I wonder whether we should do it.  After that long time,
most code likely has adapted to do this manually (or doesn't use
relative paths in the first place), and some code may even use the
CWD reset on purpose (BC break).

Anyhow, this change is unlikely to happen, unless somebody submits
a PR.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 18:01:34 2024 UTC