|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58608 require_once fails
Submitted: 2009-03-31 09:01 UTC Modified: 2009-04-06 16:06 UTC
From: spcmky at gmail dot com Assigned:
Status: Duplicate Package: APC (PECL)
PHP Version: 5.2.9 OS: Linux
Private report: No CVE-ID: None
 [2009-03-31 09:01 UTC] spcmky at gmail dot com
In the error logs:
[apc-error] Cannot redeclare class zend_cache_core

Without APC enabled everything works properly.  With APC version 3.0.19 everything works properly.  With APC version 3.1.2 I get the above error.

I'm using Zend Framework and have an initializer plugin that sets up all the configs, db connections, routes, etc.  It is called via the bootstrap.  In the Zend/Cache.php file on line 174, I found that if I test to see if the class exists before attempting to include the class file then the error goes away and all is well again.

Reproduce code:
This is the constructor function in the front controller plugin.  I setup two caches but it errors at the first one.  I am including all the classes I use in the file before the plugin class declaration

public function __construct ()
  $this->_front = Zend_Controller_Front::getInstance();
  // Init Local Cache

It will load the first time, after clearing apc, but never again due to the error.

Expected result:
I expect that the require_once for the cache class in the initializer file would register with apc/php so that it wouldn't try to include it again.

Actual result:
[apc-error] Cannot redeclare class zend_cache_core


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-03-31 09:02 UTC] spcmky at gmail dot com
In the bootstrap.php file this calls the plugin:

require_once 'Initializer.php';

// Prepare the front controller.
$frontController = Zend_Controller_Front::getInstance();

// Initialize the app
$frontController->registerPlugin(new Initializer());
 [2009-03-31 18:18 UTC]
Thanks for the bug report, could attempt to create a smaller reproduction that doesn't require the Zend Framework?
 [2009-03-31 20:26 UTC] spcmky at gmail dot com
Np.  Am already working on it.  I'll post a code sample or url soon.
 [2009-04-01 17:22 UTC]
Fantastic, thank you.
 [2009-04-06 15:54 UTC] spcmky at gmail dot com
I cannot recreate this bug with a simple example.  I have isolated the bug to apc.include_once_override though.  When off there is no issue.

The problem occurs for me when I try to create two different cache objects.  On the second call, it tries to include a file that is already included which causes a redeclaration error.

Wish I could provide more information.
 [2009-04-06 16:06 UTC]
Sounds like this is a duplicate of bug #15356 then:

Unfortunately the include_once_override is experimental with known issues, so my recommendation is to just not use that for now.  Thanks for narrowing this down, going to mark this bug as a dup for now but if you find this is incorrect please let us know.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 29 08:01:32 2024 UTC