From:             S dot Bennett at lancaster dot ac dot uk
Operating system: Linux
PHP version:      4.3.2
PHP Bug Type:     Directory function related
Bug description:  getcwd() returns random results in a callback

Description:
------------
The current working directory seems to set to random values  under certain
circumstances. e.g. getcwd() returns inconsistent values (as shown in the
sample code) and attempts to reference files by relative paths work
intermittently or not at all (which is how I discovered this bug..). 

Other variations on this code (eg calling getcwd() from an ob_start()
callback) appear to give similar results.

The code works fine from the command line (ie produces the expected
result).

I've configured PHP with the following, and still been able to reproduce
the result:
./configure --prefix=/usr/local/packages/php-4.3.2
--with-apxs=/usr/local/packages/apache-1.3.27/bin/apxs

I've also reproduced this problem on a Solaris box, also running Apache
1.3.27.



Reproduce code:
---------------
<?PHP
print "current time is '".strftime("%D %T")."'<br>\n";
print "(in main) cwd is '".getcwd()."'<br>\n";
register_shutdown_function("atexit");

function atexit()
{
    print "(in callback) cwd is '".getcwd()."'<br>\n";
}
?>


Expected result:
----------------
Something like:
current time is '06/30/03 18:39:24'
(in main) cwd is '/home/steveb/public_html/callbacktest'
(in callback) cwd is '/home/steveb/public_html/callbacktest'

Actual result:
--------------
actual results vary, here's two. All I did in between them was press
'reload'...

output 1:
---------
current time is '06/30/03 18:59:24'
(in main) cwd is '/home/steveb/public_html/callbacktest'
(in callback) cwd is '/home/www/vhosts/nutter.spoo.org/htdocs'

output 2:
---------
current time is '06/30/03 18:59:34'
(in main) cwd is '/home/steveb/public_html/callbacktest'
(in callback) cwd is '/home/steveb/public_html'

The values returned by getcwd() appear to be related to previous pages
that have been served by apache (not necessarily ones that have been
processed by PHP).


-- 
Edit bug report at http://bugs.php.net/?id=24420&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=24420&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=24420&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=24420&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=24420&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=24420&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=24420&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=24420&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=24420&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=24420&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=24420&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24420&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=24420&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=24420&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=24420&r=gnused

Reply via email to