php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32967 __FILE__ has relative path: Should always be absolute
Submitted: 2005-05-06 18:02 UTC Modified: 2005-06-14 01:00 UTC
Votes:12
Avg. Score:4.6 ± 0.6
Reproduced:11 of 11 (100.0%)
Same Version:2 (18.2%)
Same OS:0 (0.0%)
From: oskar-phpbug at eyb dot de Assigned:
Status: No Feedback Package: *General Issues
PHP Version: 5.0.4 OS: FreeBSD 5.3
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2005-05-06 18:02 UTC] oskar-phpbug at eyb dot de
Description:
------------
It seems a never fixed problem with __FILE__

It looks like this description:

http://bugs.php.net/bug.php?id=13936


After I updatetd because this bug from PHP 4.3.11 to 5.0.4, unfortunately, there is the same problem.


I would be very grateful if this can be fixed now.

Reproduce code:
---------------
In install/steps/SystemChecksStep.class of the Gallery2 - Distribution there is the following code of interest:


function CheckFileDirective() {
if (strstr(__FILE__, 'install/steps/SystemChecksStep.class') ||
strstr(__FILE__, '\\install\\steps\\SystemChecksStep.class')) {
return true;
} else {
return false;
}
} 

Expected result:
----------------
__FILE__ should return the full path, that is the absolute path, of the file where it's called in.

__FILE__ returning a relative path is a known php problem and should have been fixed by now.

it seems that PHP couldn't fix it for all system, i.e. obviously it doesn't work on your freebsd machine. 

Actual result:
--------------
If I write above the if (...)

die('__FILE__ = ' . __FILE__);


then in the browser appears

__FILE__ = ./steps/SystemChecksStep.class

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-18 17:18 UTC] tony2001@php.net
What SAPI are you using?
Does it work with CLI ?
 [2005-05-18 20:10 UTC] tony2001@php.net
And please check that you don't have any of zend_extension's loaded.
 [2005-05-18 21:58 UTC] oskar-phpbug at eyb dot de
SAPI  [  php_sapi_name()  ]  is "apache" (mod_php)

I've currently the following extensions loaded (no zend..)

extension=bcmath.so
extension=bz2.so
extension=ctype.so
extension=curl.so
extension=dom.so
extension=exif.so
extension=ftp.so
extension=gd.so
extension=gettext.so
extension=iconv.so
extension=imagick.so
extension=imap.so
extension=ldap.so
extension=mbstring.so
extension=mcrypt.so
extension=mcve.so
extension=mhash.so
extension=ming.so
extension=mysql.so
extension=openssl.so
extension=pcre.so
extension=pdf.so
extension=pgsql.so
extension=posix.so
extension=readline.so
extension=session.so
extension=simplexml.so
extension=sqlite.so
extension=tokenizer.so
extension=wddx.so
extension=xmlrpc.so
extension=zlib.so
 [2005-05-27 09:14 UTC] sniper@php.net
Zend extensions are loaded with (surprise surprise):

  zend_extension=/path/to/some/zend_extension.so

Disable all the shared modules you're running and see if you get the same result.

 [2005-05-27 19:14 UTC] oskar-phpbug at eyb dot de
In one vhost it works the following test, in another it doesn't.


create in /home/whatever/www/test.php
and in /home/whatever/www/sub1/testsub1.php
and in /home/whatever/www/sub1/sub2/testsub2.php

--- test.php
<?php
print __FILE__;
print "<br>";
require("./sub1/testsub1.php");
?>

--- testsub1.php
<?php
print __FILE__;
print "<br>";
require("./sub1/sub2/testsub2.php");
?>

--- testsub2.php
<?php
print __FILE__;
?>

Result in vhost1
-------------------
/home/whatever/www/test.php
/home/whatever/www/sub1/testsub1.php
/home/whatever/www/sub1/sub2/testsub2.php 


Result in vhost2
-------------------
/home/whatever/www2/test.php
./sub1/testsub1.php
./sub1/sub2/testsub2.php


I can't find no difference between the vhosts, in which its OK and the "disfunctional".

In the diffs of both phpinfo() there are only vars like Hostname:Port, DOCUMENT_ROOT, HTTP_POST, SERVER_ADMIN, SERVER_NAME, UNIQUE_ID etc differential.

But there must exist one?!


httpd is Apache 1.3.33 


This one is OK:

<VirtualHost *:80>
    ServerAdmin www@...
    DocumentRoot /.../htdocs
    ServerName ...
    ServerAlias www....
    ErrorLog /.../error_log
    CustomLog /.../access_log combined

<Directory /.../htdocs>
        AllowOverride Options FileInfo
</Directory>
</VirtualHost>


This one not:
<VirtualHost *:80>
    ServerAdmin www@...
    DocumentRoot /.../htdocs
    ServerName ...
    ServerAlias www....
    ErrorLog /.../www2/error_log
    CustomLog /.../www2/access_log combined

<Directory /.../htdocs>
        AllowOverride Options FileInfo
</Directory>
</VirtualHost>


The filesystem of these vhosts is the same.
In the first vhost I can of course install gallery2 without any problems...
 [2005-06-06 10:09 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2005-06-14 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-06-29 01:39 UTC] kwerle at pobox dot com
I continue to have this problem with

PHP 5.1.4 (cli) (built: Jun 27 2006 20:57:37) 
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies


The cvs snapshot is no longer available.
This on OSX.
 [2006-06-29 01:48 UTC] kwerle at pobox dot com
Ah-ha!  Part of the path was not readable/executable.  For 
some reason the original path (when doing the above 
experiment) was discoverable, but the child file was not.  It 
seems like there should be some kind of fix for this, as it 
doesn't make sense for this to happen.

I will try to isolate a trivial test case to reproduce this 
and submit it.
 [2006-07-05 04:56 UTC] kwerle at pobox dot com
Please see http://bugs.php.net/bug.php?id=34552 for the true 
cause and solution.
 [2006-07-05 04:57 UTC] kwerle at pobox dot com
Please see http://bugs.php.net/bug.php?id=34552 for the cause 
and solution.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 08:01:29 2024 UTC