php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16409 include_once includes multiple times
Submitted: 2002-04-03 06:13 UTC Modified: 2002-08-22 12:32 UTC
From: michael at janneck dot de Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 4.1.2 OS: Mac OS X 10.1.3
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: michael at janneck dot de
New email:
PHP Version: OS:

 

 [2002-04-03 06:13 UTC] michael at janneck dot de
There is a bug with include_once including a file twice, if it is referenced once with a fully qualified path and once with only the filename (and the file being in the include path). This script illustrates what I mean:

include_once('x.php');
include_once('/home/janneck/public_html/x.php');

On my Mac OS X 10.1.3, Apache 1.3.22, PHP 4.1.2 (also: 4.0.6) system, this results in x.php getting included twice. (It works as expected on RedHat 7.1, Apache 1.3.22, PHP 4.0.6.)

doing "var_dump(get_included_files());" shows the following:

array(2) { [0]=> string(6) "/x.php" [1]=> string(40) "/home/janneck/public_html/x.php" }

This might be related to a problem with the "realpath()" function which does not work correctly but returns "" all the time.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-06 12:31 UTC] markonen@php.net
I cannot reproduce this on either the Apple-supplied PHP 
4.1.2 or a fresh 4.3.0-dev build, running on the default 
Apache installation (1.3.22).

realpath() also works as expected.

Can you install Apple's new Security Update, which includes 
PHP 4.1.2? If it works for you, we can start narrowing down 
why it doesn't work on your custom PHP build.
 [2002-04-09 07:12 UTC] michael at janneck dot de
I installed the update and it still did not work for me. I then looked where there might be a problem with my installation and finally found, that the problem occurs, if the webserver does not have read access to all directories on the path to the script file. I had my home dir set to rwx--x--x for privacy reasons. Giving read-access for the world, solved the problem.

I don't know if there is a way to solve this problem, but it is definitely not nice, that the functions do not work correctly depending on access rights.
 [2002-05-17 05:24 UTC] preston dot bannister at cox dot net
I'd suggest that if include_once() is given two distinct paths that just happen to work out the to same file, asking PHP to figure out that these are the same file is too much trouble.

There are too many tricky cases (like the permissions case documented here) that are difficult or impossible to get right.  On Win32 you could have UNC and local names pointing to the same file.  On Unix you could hard and soft links pointing to the same file.  Sounds like a lot of trouble :).

Probably the safest bet is to document include_once() and require_once() as determining file identity strictly by name.
 [2002-08-22 12:32 UTC] iliaa@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.


 [2014-07-03 17:56 UTC] thinsoldier at thinsoldier dot com
FYI for anyone else experiencing his, this include_once bug still exists up to  php 5.3.15. and possibly later.
 [2015-05-26 16:49 UTC] btomasik at telkonet dot com
Believe we are also experiencing this still in OSX 10.9.5 on PHP-5.4.38
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 21:01:28 2024 UTC