Ticket #109 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

Enabling eaccelerator breaks handling of constants

Reported by: anonymous Assigned to: somebody
Priority: blocker Milestone: 0.9.5
Component: eAccelerator Version: 0.9.5
Keywords: constants Cc: tony@crosswinds.net

Description (Last modified by bart)

I avoid using (require|include)_once and instead, use constant define at the top of my php files to avoid redefining classes/functions.

At the top of a file I will have (say query.php):

<?php
  global $query;  // Shared global reference
   
  if (defined('_QUERY_PHP_')) {
    return;  // return and do no more processing
  }
  define('_QUERY_PHP_', 1);

  class query {
  ... rest of file with class/functions
  }
  $query = new query;
?>

When I have eaccelerator off, it works as expected. When I turn it on, I get

Fatal error: Cannot redeclare class query in [snipped]/query.php on line 0

FreeBSD 4.11 Apache/1.3.34 (Unix) PHP/4.4.2 mod_ssl/2.8.25 OpenSSL/0.9.7d Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies with eAccelerator v0.9.5-beta2, Copyright (c) 2004-2006 eAccelerator, by eAccelerator with Zend Extension Manager v1.0.9, Copyright (c) 2003-2005, by Zend Technologies with Zend Optimizer v2.6.0, Copyright (c) 1998-2005, by Zend Technologies

zend_extension="/usr/local/lib/php/20020429/eaccelerator.so" eaccelerator.enable="0" eaccelerator.shm_size="0" eaccelerator.cache_die="/tmp/eaccelerator" eaccelerator.optimizer="1" eaccelerator.debug="0" eaccelerator.log_file="/var/log/eaccelerator.log" eaccelerator.name_space="" eaccelerator.check_mtime="1" eaccelerator.filter="" eaccelerator.shm_max="0" eaccelerator.shm_ttl="0" eaccelerator.shm_prune_period="0" eaccelerator.shm_only="0" eaccelerator.compress="1" eaccelerator.compress_level="9" eaccelerator.keys="shm_and_disk" eaccelerator.session="shm_and_disk" eaccelerator.content="shm_and_disk" eaccelerator.allowed_admin_path = "/usr/local/www/admin/ea"

Change History

06/07/06 18:38:14 changed by anonymous

The formatting when I inserted the code has been borked

The if clause is on the next line, as is the $query = line...

06/22/06 12:30:09 changed by Stadler

Looks, like this is related to the problems, when returning from an included script. See Ticket #31 for example.

Regards,

Christian Stadler

06/26/06 14:46:37 changed by bart

  • description changed.

06/26/06 14:53:37 changed by bart

  • priority changed from major to blocker.
  • version set to 0.9.5.
  • milestone set to 0.9.5.

06/26/06 17:33:57 changed by bart

I found the problem. When eAccelerator is enabled eA will restore the classes a second time before the code is executed. This results in the duplicate class error. I hope you realise that not using (require|include)_once introduces a real performance penalty, a lot more then just using the _once version everwhere.

06/27/06 12:12:56 changed by bart

  • status changed from new to closed.
  • resolution set to fixed.

This is fixed in revision [220]