php.net |  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 (profile)
Status: Closed Package: *General Issues
PHP Version: 5.0.4 OS:
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: stas at zend dot com
New email:
PHP Version: OS:

 

 [2005-05-03 11:35 UTC] stas at zend dot com
Description:
------------
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:
---------------
1. 
<? include('foo'); include_once('foo'); ?>
foo:
<? echo "Whatever..."; ?>

2.
auto_prepend_file=foo
<? include_once('foo'); ?>

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

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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-04 18:17 UTC] stas@php.net
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
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2005-05-04 18:18 UTC] stas@php.net
Fixed for 5HEAD.
 [2005-05-06 12:26 UTC] derick@php.net
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] sniper@php.net
It's exactly same now how it works in PHP4 too.



 [2005-05-09 12:00 UTC] stas@php.net
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-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 14:01:29 2024 UTC