From:             stefan dot priebsch at e-novative dot de
Operating system: Win2K, WinXP
PHP version:      4.3.2
PHP Bug Type:     Scripting Engine problem
Bug description:  Case problem with internal list of included files handling

Description:
------------
When the same file is include_once'd multiple times, but with a different
case, PHP does not recognize that actually the same file is included
multiple times. This can lead to "cannot redefine function (resp. class)"
errors.

>From looking at the array returned by get_included_files, it seems that
PHP handles the list in a case-sensitive way, which obviously is wrong
since Win path and file names are not case sensitive.

To reproduce the error, create main.php and include.php using the code
below. The example produces a "cannot redefine" error, which is unexpected
behaviour.

When commenting out the function definition and running the example again,
one can see that the included file name appears twice in the list, but
with different case.

Reproduce code:
---------------
main.php:

  print 'main ';
  
  include_once ('include.php');
  print_r (get_included_files ());
  
  include_once ('Include.php');
  print_r (get_included_files ());

include.php:

  print 'included file ';

  function included_fn ()
  {
    print 'included fn ';
  } 


Expected result:
----------------
main included file Array ( [0] => main.php [1] => include.php ) included
file 

[full paths removed for clarity]

Actual result:
--------------
main included file Array ( [0] => main.php [1] => include.php ) included
file 
Fatal error: Cannot redeclare included_fn() (previously declared in
include.php:7) in Include.php on line 5

[full paths removed for clarity]

-- 
Edit bug report at http://bugs.php.net/?id=24671&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=24671&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=24671&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=24671&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=24671&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=24671&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=24671&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=24671&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=24671&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=24671&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=24671&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=24671&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24671&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=24671&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=24671&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=24671&r=gnused

Reply via email to