Skip to content

Commit 3701516

Browse files
Girgiasdunglas
andauthored
refactor: call opcache_reset PHP function directly (#1401)
* Call opcache_reset PHP function directly * prevent warning * cleanup * remove frankenphp_execute_php_function * cs --------- Co-authored-by: Kévin Dunglas <kevin@dunglas.fr>
1 parent f36bd51 commit 3701516

File tree

3 files changed

+5
-31
lines changed

3 files changed

+5
-31
lines changed

frankenphp.c

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,30 +1161,13 @@ int frankenphp_execute_script_cli(char *script, int argc, char **argv) {
11611161
return (intptr_t)exit_status;
11621162
}
11631163

1164-
int frankenphp_execute_php_function(const char *php_function) {
1165-
zval retval = {0};
1166-
zend_fcall_info fci = {0};
1167-
zend_fcall_info_cache fci_cache = {0};
1168-
zend_string *func_name =
1169-
zend_string_init(php_function, strlen(php_function), 0);
1170-
ZVAL_STR(&fci.function_name, func_name);
1171-
fci.size = sizeof fci;
1172-
fci.retval = &retval;
1173-
int success = 0;
1174-
1175-
zend_try { success = zend_call_function(&fci, &fci_cache) == SUCCESS; }
1176-
zend_end_try();
1177-
1178-
zend_string_release(func_name);
1179-
1180-
return success;
1181-
}
1182-
11831164
int frankenphp_reset_opcache(void) {
1184-
if (zend_hash_str_exists(CG(function_table), "opcache_reset",
1185-
sizeof("opcache_reset") - 1)) {
1186-
return frankenphp_execute_php_function("opcache_reset");
1165+
zend_function *opcache_reset =
1166+
zend_hash_str_find_ptr(CG(function_table), ZEND_STRL("opcache_reset"));
1167+
if (opcache_reset) {
1168+
zend_call_known_function(opcache_reset, NULL, NULL, NULL, 0, NULL, NULL);
11871169
}
1170+
11881171
return 0;
11891172
}
11901173

frankenphp.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -653,13 +653,6 @@ func freeArgs(argv []*C.char) {
653653
}
654654
}
655655

656-
func executePHPFunction(functionName string) bool {
657-
cFunctionName := C.CString(functionName)
658-
defer C.free(unsafe.Pointer(cFunctionName))
659-
660-
return C.frankenphp_execute_php_function(cFunctionName) == 1
661-
}
662-
663656
func timeoutChan(timeout time.Duration) <-chan time.Time {
664657
if timeout == 0 {
665658
return nil

frankenphp.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ int frankenphp_execute_script(char *file_name);
6363

6464
int frankenphp_execute_script_cli(char *script, int argc, char **argv);
6565

66-
int frankenphp_execute_php_function(const char *php_function);
67-
6866
void frankenphp_register_variables_from_request_info(
6967
zval *track_vars_array, zend_string *content_type,
7068
zend_string *path_translated, zend_string *query_string,

0 commit comments

Comments
 (0)