@@ -239,11 +239,16 @@ static void frankenphp_update_request_context() {
239239#if PHP_VERSION_ID < 80300
240240 zend_function * func = zend_hash_str_find_ptr (
241241 CG (function_table ), "opcache_reset" , sizeof ("opcache_reset" ) - 1 );
242- if (func != NULL && func -> type == ZEND_INTERNAL_FUNCTION ) {
242+ if (func != NULL && func -> type == ZEND_INTERNAL_FUNCTION &&
243+ ((zend_internal_function * )func )-> handler !=
244+ ZEND_FN (frankenphp_opcache_reset )) {
243245 pthread_mutex_lock (& opcache_reset_mutex_php_82 );
244- orig_opcache_reset = ((zend_internal_function * )func )-> handler ;
245- ((zend_internal_function * )func )-> handler =
246- ZEND_FN (frankenphp_opcache_reset );
246+ if (((zend_internal_function * )func )-> handler !=
247+ ZEND_FN (frankenphp_opcache_reset )) {
248+ orig_opcache_reset = ((zend_internal_function * )func )-> handler ;
249+ ((zend_internal_function * )func )-> handler =
250+ ZEND_FN (frankenphp_opcache_reset );
251+ }
247252 pthread_mutex_unlock (& opcache_reset_mutex_php_82 );
248253 }
249254#endif
@@ -1685,6 +1690,9 @@ int frankenphp_execute_script_cli(char *script, int argc, char **argv,
16851690}
16861691
16871692int frankenphp_reset_opcache (void ) {
1693+ if (orig_opcache_reset == NULL ) {
1694+ return 0 ; // perhaps raise a warning here and fall through to calling the original?
1695+ }
16881696 zend_execute_data execute_data ;
16891697 zval retval ;
16901698 memset (& execute_data , 0 , sizeof (execute_data ));
0 commit comments