php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33529 __FILE__ is relative while running Apache SAPI
Submitted: 2005-06-30 22:56 UTC Modified: 2005-08-31 01:00 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: ohill@php.net Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 5CVS, 4CVS (2005-07-03) OS: Mac OS X
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ohill@php.net
New email:
PHP Version: OS:

 

 [2005-06-30 22:56 UTC] ohill@php.net
Description:
------------
The content of the __FILE__ constant is relative while running through a Virtual Host on OS X.

The bug is not seen while working with the CLI version or if the script is not in a VirtualHost directive.

Configure is as follow (majorly taken from OS X compile flags):
'./configure' '--prefix=/usr' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--with-apxs' '--enable-cli' '--with-zlib' '--with-xml' '--enable-exif' '--enable-ftp' '--enable-sockets' '--with-curl=/usr' '--with-config-file-path=/etc' '--sysconfdir=/private/etc'

Apache is the one distributed with Tiger 10.4.1 (1.3.33).

The same code runs fine on Linux and Windows with the same config (vhosts settings).

Reproduce code:
---------------
<?php print __FILE__;


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-01 05:31 UTC] ohill@php.net
If you try with 2 scripts:

/index.php
/something/index.php

and /index.php contains print __FILE__ and /something/index.php contains include('../index.php'), if you point your browser to /index.php the content of __FILE__ is correct.

If you try /something/index.php, __FILE__ will contains '../index.php'
 [2005-07-02 15:45 UTC] sniper@php.net
Does this happen with PHP 5.1-dev?

http://snaps.php.net/php5-latest.tar.gz

 [2005-07-03 01:58 UTC] ohill@php.net
Yes, same result with 5.1.0-dev (indeed)
 [2005-08-23 02:27 UTC] sniper@php.net
Can you explain me why I can't reproduce this on same Macosx version, same apache version and PHP 4.4.0 ??
(yes, I tested within a virtualhost and a subdir in it)

Does your setup have some symlinks somewhere in the path?

 [2005-08-31 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2006-04-05 14:53 UTC] romaninsh at gmail dot com
I am experiencing the same thing (see also bug #27823 which 
look like a same issue)

a.php:
<?
echo "<pre>";
var_dump(__FILE__);
include"b.php";

b.php:
<?
var_dump(__FILE__);

output:
string(31) "/Users/r/Sites/a.php"
string(7) "./b.php"

expected:
string(31) "/Users/r/Sites/a.php"
string(31) "/Users/r/Sites/b.php"

URL opened:
http://localhost/a.php

httpd.conf:
DocumentRoot "/Users/r/Sites"

php version: 
php-5.1.2

mac os x (intel)

php configure string:
'./configure' \
'--with-xml' \
'--with-zlib' \
'--with-gd' \
'--with-jpeg-dir=/sw' \
'--with-png-dir=/sw' \
'--with-apxs=/usr/sbin/apxs' \
'--with-mysql' \
'--with-mysql=/usr/local/mysql'

I AM USING NON-CVS version. I'm going to upgrade NOW and 
will report if it solves the problem.
 [2006-04-05 15:00 UTC] romaninsh at gmail dot com
more info
 macosx version: 1.4.6
 apache verison: 1.3.33 (Darwin), default one.

I can't reproduce this problem with:
 http://www.entropy.ch/software/macosx/php/ (which is 5.1.2) 
on PowerPPC
 on Linux / Apache2
 [2006-04-05 16:31 UTC] romaninsh at gmail dot com
Ok, I have tried latest CVS and it have the same problem:

PHP Version 5.1.3RC3-dev
checkout / build date: 5 Apr 2006
 [2006-04-05 16:37 UTC] romaninsh at gmail dot com
I played a bit more with getcwd and it would also return 
false. Then it turned out i have no read permissions for one 
of the parent directory. Just as manual says, in this case 
getcwd returns false. 

I have changed permission on that directory and now everything 
works as expected.

If anyone have this issue, check if all the parent directories 
are readable by apache.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC