php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57091 Handling of defined constants from included files
Submitted: 2006-06-15 09:28 UTC Modified: 2006-08-21 19:15 UTC
From: damien dot mirand at laposte dot net Assigned: gopalv (profile)
Status: Closed Package: APC (PECL)
PHP Version: 5.1.2 OS: Linux
Private report: No CVE-ID: None
 [2006-06-15 09:28 UTC] damien dot mirand at laposte dot net
Description:
------------
When using defined constants to ensure each include class 
file is only included once, it produces an error 
complaining that the specified class has already been 
defined, despite the defined constant normally prevents 
it. 
 

Reproduce code:
---------------
--test_bug_1.php--
<?php
include( 'test_bug_1.inc' ) ;
include( 'test_bug_1.inc' ) ;
?>

--test_bug_1.inc--
<?php
if( !defined('FOOFOO') )
{
	define('FOOFOO',TRUE) ;
	class Foofoo {}
}
?>


Expected result:
----------------
Works with no error. 

Actual result:
--------------
Fatal error: Cannot redeclare class 
in /srv/www/htdocs/op4demo/html/test_bug_1.php on line 3 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-06-15 13:46 UTC] rasmus@php.net
Which APC version?  Try current CVS.  I think this is fixed.
 [2006-06-15 19:52 UTC] damien dot mirand at laposte dot net
Same with CVS.    
v. 3.0.10 & 3.0.9 are affected.    
v. 3.0.8 and older are not.    
    
In fact it also occurs with :    
  
--test_bug_1.php--  
<?php  
include( 'test_bug_1.inc' ) ;  
include( 'test_bug_1.inc' ) ;  
?>    
  
--test_bug_1.inc--   
<?php   
if( !class_exists('Foofoo') )   
{   
	class Foofoo {}   
}   
?>  
  
It seems that a class include file cannot be included more  
than once, even if there's "checks" on it. By checks I  
mean defined constants, or even the 'class_exists' method.
 [2006-07-05 05:03 UTC] gopalv82 at yahoo dot com
Mangled name issues.

Will be dealing with in the next two weeks.
 [2006-07-27 10:00 UTC] gopalv82 at yahoo dot com
Double includes of the same file results in de-dup code while compiling. This taken care of by the zend compiler and requires a recompile of the file *or* a fixup of the class names through out the opcode stream.
 [2006-08-21 15:39 UTC] gopalv82 at yahoo dot com
Fixed in CVS on 22nd August 2006.

Please obtain apc_main.c,3.80 for a fix for this problem.

Confirm fix, please.
 [2006-08-21 19:15 UTC] damien dot mirand at laposte dot net
Works fine now. 
Thanks !
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 13 20:01:34 2024 UTC