php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42570 require not finding files that are within filesystem
Submitted: 2007-09-05 19:02 UTC Modified: 2007-09-06 22:26 UTC
From: development at domain51 dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.2.4 OS: Mac OS X 10.4
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: development at domain51 dot com
New email:
PHP Version: OS:

 

 [2007-09-05 19:02 UTC] development at domain51 dot com
Description:
------------
When including/requiring file within the scripts path, it does not pay attention to the original scripts path.  file_exists() and is_readable() will return true, but require/include will produce an error.

Reproduce code:
---------------
<?php
// base-file.php
require 'include/some-file.php';
?>
<?php
// include/some-file.php
require 'file-that-exists.php';
?>
<?php
// file-that-exists.php
echo "Hello, I exist";
?>

Expected result:
----------------
Hello, I exist

Actual result:
--------------
Warning: include(file-that-exists.php) [function.include]: failed to open stream: No such file or directory in /path/to/some-file.php on line 3

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-05 19:10 UTC] development at domain51 dot com
I just attempted this code on a Linux (Ubuntu Feisty Fawn, Server) and did not receive the warning/fatal error.  Copying that code back to my Mac OS X box, the code did have the same error.

This appears to be OS X related.

The code to reproduce is available from: http://plumb.domain51.com/sandbox/bug42570.tar.bz2
 [2007-09-06 10:58 UTC] jani@php.net
What did you set include_path to be? And where are the files located..?
(it's not very clear now..)
 [2007-09-06 15:05 UTC] development at domain51 dot com
Sorry for not being more explicit.

The include_path is not touched during this execution and is left as it 
is compiled from the base.  In this case, the Mac's include_path is set 
to "/path/to/php" where the PEAR files are stored without the "./:" at 
the beginning as is the normal php.ini file setup.

Properly setting the include_path does handle this, though for some 
reason I had it in my head that the current working path was always 
prepended to the include_path.

Feel free to mark as bogus...
 [2007-09-06 22:26 UTC] jani@php.net
Current working dir isn't used by default. So this is bogus.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jul 05 17:01:31 2024 UTC