|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32924 file included with "auto_prepend_file" can be called with require|include_once()
Submitted: 2005-05-03 11:35 UTC Modified: 2005-05-09 12:00 UTC
From: stas at zend dot com Assigned: stas
Status: Closed Package: *General Issues
PHP Version: 5.0.4 OS:
Private report: No CVE-ID:
 [2005-05-03 11:35 UTC] stas at zend dot com
At least starting from 4.3.x, when file is included via include(), it is added to the list of included files, so that the code:
<? include('foo'); include_once('foo'); ?>
woould include 'foo' only once.

However, if you put foo in auto_prepend_file and then do <? include_once('foo'); ?> - 'foo' would be included twice.

I see this behaviour as inconsistent and needing to be fixed, though there can be some BC issues with that. 

Reproduce code:
<? include('foo'); include_once('foo'); ?>
<? echo "Whatever..."; ?>

<? include_once('foo'); ?>

Expected result:
"Whatever..." once in both cases

Actual result:
"Whatever..."  once in the first case, twice in the second.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-04 18:17 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

 [2005-05-04 18:18 UTC]
Fixed for 5HEAD.
 [2005-05-06 12:26 UTC]
IMO, the following SHOULD include the file twice:
<? include('foo'); include_once('foo'); ?>

normal includes should not get their file names put into the included_files list... only ones that are included with include_once/require_once. So I think you fixed the bug in the wrong way here.
 [2005-05-09 11:35 UTC]
It's exactly same now how it works in PHP4 too.

 [2005-05-09 12:00 UTC]
I don't think there's any problem with the fix - since include() is not supposed to check included files, this fix does not affect include() in any way.
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Sat Nov 28 02:01:31 2015 UTC