Skip to content

Instantly share code, notes, and snippets.

@laruence
Created March 10, 2013 15:52
Show Gist options
  • Save laruence/5129104 to your computer and use it in GitHub Desktop.
Save laruence/5129104 to your computer and use it in GitHub Desktop.
apc.enable_opcode_cache
Index: apc_main.c
===================================================================
--- apc_main.c (revision 329723)
+++ apc_main.c (working copy)
@@ -907,8 +907,11 @@
apc_user_cache = apc_cache_create(APCG(user_entries_hint), APCG(gc_ttl), APCG(user_ttl) TSRMLS_CC);
/* override compilation */
- old_compile_file = zend_compile_file;
- zend_compile_file = my_compile_file;
+ if (APCG(enable_opcode_cache)) {
+ old_compile_file = zend_compile_file;
+ zend_compile_file = my_compile_file;
+ }
+
REGISTER_LONG_CONSTANT("\000apc_magic", (long)&set_compile_hook, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("\000apc_compile_file", (long)&my_compile_file, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT(APC_SERIALIZER_CONSTANT, (long)&_apc_register_serializer, CONST_PERSISTENT | CONST_CS);
@@ -937,7 +940,10 @@
return 0;
/* restore compilation */
- zend_compile_file = old_compile_file;
+ /* override compilation */
+ if (APCG(enable_opcode_cache)) {
+ zend_compile_file = old_compile_file;
+ }
/*
* In case we got interrupted by a SIGTERM or something else during execution
Index: apc_globals.h
===================================================================
--- apc_globals.h (revision 329723)
+++ apc_globals.h (working copy)
@@ -127,6 +127,7 @@
HashTable *compiler_hook_func_table;
HashTable *compiler_hook_class_table;
int compile_nesting;
+ zend_bool enable_opcode_cache;
ZEND_END_MODULE_GLOBALS(apc)
/* (the following declaration is defined in php_apc.c) */
Index: php_apc.c
===================================================================
--- php_apc.c (revision 329723)
+++ php_apc.c (working copy)
@@ -112,6 +112,7 @@
apc_globals->compiler_hook_func_table = NULL;
apc_globals->compiler_hook_class_table = NULL;
apc_globals->compile_nesting = 0;
+ apc_globals->enable_opcode_cache = 1;
}
static void php_apc_shutdown_globals(zend_apc_globals* apc_globals TSRMLS_DC)
@@ -278,6 +279,7 @@
STD_PHP_INI_BOOLEAN("apc.lazy_functions", "0", PHP_INI_SYSTEM, OnUpdateBool, lazy_functions, zend_apc_globals, apc_globals)
STD_PHP_INI_BOOLEAN("apc.lazy_classes", "0", PHP_INI_SYSTEM, OnUpdateBool, lazy_classes, zend_apc_globals, apc_globals)
STD_PHP_INI_ENTRY("apc.serializer", "default", PHP_INI_SYSTEM, OnUpdateStringUnempty, serializer_name, zend_apc_globals, apc_globals)
+STD_PHP_INI_BOOLEAN("apc.enable_opcode_cache", "1", PHP_INI_SYSTEM, OnUpdateBool, enable_opcode_cache, zend_apc_globals, apc_globals)
PHP_INI_END()
/* }}} */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment