php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #52847 Files to include are always searched for in current directory
Submitted: 2010-09-15 03:26 UTC Modified: 2010-09-15 13:11 UTC
From: mail_ben_schmidt at yahoo dot com dot au Assigned: aharvey (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.3.2 OS: Mac OS X 10.6.2
Private report: No CVE-ID: None
 [2010-09-15 03:26 UTC] mail_ben_schmidt at yahoo dot com dot au
Description:
------------
The documentation at include and include_path suggests that the current directory will not be searched if a '.' is not in include path. Even though I can see no reason (e.g. in the source code referred to by bug #51569) that the current directory should be searched, it can be demonstrated that it is.

See also bug #51569 and bug #52845 for further include_path documentation deficiencies.


Test script:
---------------
1. Place in a file 'test/test.php':

set_include_path('/bin'); // won't find any php files here!
include('another.php');

2. touch another.php

3. php test/test.php


Expected result:
----------------
Warning that another.php cannot be found.


Actual result:
--------------
No warning.

N.B. In line with the undocumented feature mentioned in bug #51569, if another.php is moved to test/another.php, it is still found also, because it is in the directory of the running script.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-09-15 03:32 UTC] mail_ben_schmidt at yahoo dot com dot au
-Package: Documentation problem +Package: Scripting Engine problem -Operating System: +Operating System: Mac OS X 10.6.2 -PHP Version: Irrelevant +PHP Version: 5.3.2
 [2010-09-15 03:32 UTC] mail_ben_schmidt at yahoo dot com dot au
Actually, this may be a behaviour problem, not a documentation problem.
 [2010-09-15 08:43 UTC] aharvey@php.net
-Status: Open +Status: Duplicate
 [2010-09-15 08:43 UTC] aharvey@php.net
This is intended behaviour: php_resolve_path() includes a fallback case at the end to search the directory the currently executing file lives in if all else fails.

I'll update the documentation. Duping to doc bug #51569.
 [2010-09-15 10:22 UTC] mail_ben_schmidt at yahoo dot com dot au
Please read this bug report more carefully. The included file is *not* in "the directory the currently executing file lives in" which is what #51569 addresses, and is the intended fallback behaviour. It is merely in the current working directory. (For many SAPIs this is the same initially, but not for the CLI, for instance, and not when a script has been included from another script running in a different directory.) The documentation suggests the current working directory will only be searched if "." is in include_path. This is false. The current directory is being searched anyway. I don't know if this is a behaviour or documentation problem. (The directory where the current script lives is being searched, too, but that is the subject of #51569, and undeniably a documentation problem.)
 [2010-09-15 11:32 UTC] aharvey@php.net
-Status: Duplicate +Status: Assigned -Type: Bug +Type: Documentation Problem -Package: Scripting Engine problem +Package: Documentation problem -Assigned To: +Assigned To: aharvey
 [2010-09-15 11:32 UTC] aharvey@php.net
Ah, I see now. It's happening further up the call chain -- after php_resolve_path() has failed to find anything using the include path, _php_stream_open_wrapper_ex() tries the plain file stream, which does look in the current working directory.

Nothing we can do about it in terms of behaviour; it's just part of providing the option of including from URL streams. I'll document it.
 [2010-09-15 11:35 UTC] aharvey@php.net
Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&revision=303387
Log: Fix doc bug #52847 (Files to include are always searched for in current
directory).
 [2010-09-15 11:35 UTC] aharvey@php.net
-Status: Assigned +Status: Closed
 [2010-09-15 11:35 UTC] aharvey@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 [2010-09-15 13:11 UTC] mail_ben_schmidt at yahoo dot com dot au
Aha! That explains it. If you haven't done so anyway, I would recommend mentioning in the documentation that this check relative to the current directory will be the second such check, if "." is part of include_path.

Your speed in responding to these reports is terrific. Thanks so much.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 16 13:01:29 2024 UTC