php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18908 Not getting Current Working Directory
Submitted: 2002-08-14 18:57 UTC Modified: 2002-08-15 11:02 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: duke at mastre dot com Assigned:
Status: Closed Package: Apache2 related
PHP Version: 4CVS-2002-08-14 OS: Linux 2.4.19
Private report: No CVE-ID: None
 [2002-08-14 18:57 UTC] duke at mastre dot com
Apache: 2.0.40
PHP: php4-STABLE-200208140900
not much else

Why am I running a snapshot?  Because cookies are [still] broken in 4.2.2 when running with Apache2, and I need to run Apache2.


Problem: any/most filesystem functions do not know what the current directory is.  This is a big problem, as it's broken 85% of my scripts (also totally breaks Smarty).


Reproduce:
$ cd /var/www/html/test
$ cat test.php
<?php
	echo('current working directory: ' . getcwd() . '<br />');
	echo('w/o getcwd(): ' . (file_exists('test.php') ? 'true' : 'false') . '<br />');
	echo('with getcwd() . /: ' . (file_exists(getcwd() . '/' . 'test.php') ? 'true' : 'false'));
?>

http://somehost/test/test.php outputs this:
current working directory: /var/www/html/test
w/o getcwd(): false
with getcwd() . /: true

On 4.2.2 (rel) / 1.3.26 it correctly outputs:
current working directory: /var/www/html/test
w/o getcwd(): true
with getcwd() . /: true


Fix:  yes, please ;)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-08-14 19:17 UTC] kalowsky@php.net
Running on FreeBSD, and MacOSX I cannot reproduce this problem.. I get the following output:

current working directory: /Users/dank/Development/php4-cvs<br />
w/o getcwd(): true<br />
with getcwd() . /: true

This is from CVS HEAD.  I'm also not using Apache2 though.  Any chance you can try this with Apache 1.3.x?
 [2002-08-14 22:19 UTC] duke at mastre dot com
I'm sure it will work, my problem is on Apache2.  If I didn't need to run with Apache2 I wouldn't be using the snapshot in the first place.  I would be interested to know if you can duplicate it on FreeBSD/OS X using Apache2.

Any developer out there reading this?
 [2002-08-14 22:28 UTC] kalowsky@php.net
moving this to apache2 related.  Please realize that PHP and Apache2 is a VERY experiemental thing, and not very likely to be fixed quickly.  And yes we developers are reading this...
 [2002-08-15 11:00 UTC] duke at mastre dot com
I tried with the unstable snapshot and it works.
 [2002-08-15 11:02 UTC] duke at mastre dot com
.
 [2002-09-06 14:18 UTC] duke at mastre dot com
So PHP 4.2.3 came out today.  I am still experiencing this very same problem - PHP can't get the current working directory under Apache 2[.0.40].  It only seems to work with the unstable snapshot du jour.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 29 01:01:30 2024 UTC