From: ypae at hotmail dot com
Operating system: Windows 2003 Server
PHP version: 5.0.4
PHP Bug Type: Unknown/Other Function
Bug description: require_once includes the same file again even if
path/filename is identical
Description:
------------
When I created a lib.inc.php that has a few functions defined (e.g.
getmicrocode(), myfunction()) and try to include it on several files with
require_once, it somehow included more than once even though the end
result of 'path/filename' is identical.
My understanding of require_once limitation on Windows (or non-POSIX)
platform was that if you have mixed case with the same file name, it will
be included again. Another words, as long as you have identical
"path/filename" as part of require_once statement, it should include only
once.
As a result, since you cannot redeclare the same function within the page,
you get:
Fatal error: Cannot redeclare "functionname()" (previously declared in...
Reproduce code:
---------------
For example,
On lib.inc.php:
===============
myfunction1()
{ echo "hello!";}
myfunction2()
{ echo "hello again!";}
On index.php
============
$_my_absolute_path = 'c:/inetpub/wwwroot/';
require_once($_my_absolute_path.'lib.inc.php');
require_once($_my_absolute_path.'template.inc.php');
on template.inc.php
===================
$_my_absolute_path = 'c:/inetpub/wwwroot/';
require_once($_my_absolute_path.'lib.inc.php'); // Just in case someone
didn't call this previously
The realistic code is quite complex:
A require_once B and C
B require_once C and *D*
C require_once *D*
and *D* causes redeclare issue when I load A.
Expected result:
----------------
the second attempt to include lib.inc.php by using require_once should be
ignored because it was already loaded.
The same code running on Linux works perfectly and it used to be fine on
PHP 4.3.10
But right after I rebuild the server with PHP 5.0.4, I got the following
error:
Fatal error: Cannot redeclare myfunction1() (previously declared in...
Actual result:
--------------
the second attempt to include lib.inc.php by using require_once WAS
performed and it causes error.
--
Edit bug report at http://bugs.php.net/?id=33224&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33224&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=33224&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=33224&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=33224&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=33224&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=33224&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=33224&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=33224&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33224&r=support
Expected behavior: http://bugs.php.net/fix.php?id=33224&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=33224&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=33224&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=33224&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33224&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=33224&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=33224&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33224&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=33224&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=33224&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=33224&r=mysqlcfg