Class/function re-declaration doesn't fail RRS feed

  • Question

  • User-379892604 posted
    Hi, I've stumbled into a curious behaviour recently, when PHP is running with wincache enabled.

    It appears that the extension prevents PHP from failing with a "Fatal error: Cannot redeclare [..]" message when a file with a class or function defined is being included/required more than once. Instead, wincache chooses first declaration and skips it during other times. The PHP error gets thrown correctly when same-named function/class is being defined in different files, however.

    As a quick example, let's say we have a file "sample.php" with a function "test_function" declared inside it:


    <?php function test_function() { } ?>


    Then if we write something like this:


    require 'sample.php';
    require 'sample.php';


    .. wincache will happily let us through, while plain PHP will call us out for misbehaving. And while it's not a particularly severe bug, it would be nice to see this fixed nevertheless :-)

    Interestingly, I checked the same thing on XCache and eAccelerator, and the first one was always failing correctly, while the latter behaved just like wincache on subsequent page loads (first load throws the proper error message).

    Tuesday, January 4, 2011 8:08 PM

All replies

  • User-1672167363 posted


    I suggest that you create a new post to the existing "windcache" topics those

    topics are are actively watched.

    And after posting marked this post answered.


    Martin :)

    Saturday, January 8, 2011 6:46 AM