Skip to content

Commit 1775ca5

Browse files
AlliBalliBabadunglas
authored andcommitted
Also registers php.ini if ZEND_MAX_EXECUTION_TIMERS is disabled.
1 parent 08818af commit 1775ca5

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

frankenphp.c

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@
3333
ZEND_TSRMLS_CACHE_DEFINE()
3434
#endif
3535

36-
/* Timeouts are currently fundamentally broken with ZTS except on Linux and
37-
* FreeBSD: https://bugs.php.net/bug.php?id=79464 */
38-
#ifndef ZEND_MAX_EXECUTION_TIMERS
39-
static const char HARDCODED_INI[] = "max_execution_time=0\n"
40-
"max_input_time=-1\n\0";
41-
#endif
42-
4336
static const char *MODULES_TO_RELOAD[] = {"filter", "session", NULL};
4437

4538
frankenphp_version frankenphp_get_version() {
@@ -901,24 +894,17 @@ static void *php_main(void *arg) {
901894
sapi_startup(&frankenphp_sapi_module);
902895

903896
#ifndef ZEND_MAX_EXECUTION_TIMERS
904-
#if (PHP_VERSION_ID >= 80300)
905-
frankenphp_sapi_module.ini_entries = HARDCODED_INI;
906-
#else
907-
frankenphp_sapi_module.ini_entries = malloc(sizeof(HARDCODED_INI));
908-
if (frankenphp_sapi_module.ini_entries == NULL) {
909-
perror("malloc failed");
910-
exit(EXIT_FAILURE);
911-
}
912-
memcpy(frankenphp_sapi_module.ini_entries, HARDCODED_INI,
913-
sizeof(HARDCODED_INI));
914-
#endif
897+
/* overwrite php.ini with custom user settings and disable
898+
* max_execution_timers */
899+
char *php_ini_overrides = go_get_custom_php_ini(true);
915900
#else
916901
/* overwrite php.ini with custom user settings */
917-
char *php_ini_overrides = go_get_custom_php_ini();
902+
char *php_ini_overrides = go_get_custom_php_ini(false);
903+
#endif
904+
918905
if (php_ini_overrides != NULL) {
919906
frankenphp_sapi_module.ini_entries = php_ini_overrides;
920907
}
921-
#endif
922908

923909
frankenphp_sapi_module.startup(&frankenphp_sapi_module);
924910

phpmainthread.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,15 @@ func go_frankenphp_shutdown_main_thread() {
191191
}
192192

193193
//export go_get_custom_php_ini
194-
func go_get_custom_php_ini() *C.char {
194+
func go_get_custom_php_ini(disableExecutionTimers C.bool) *C.char {
195195
if mainThread.phpIni == nil {
196-
return nil
196+
mainThread.phpIni = make(map[string]string)
197+
}
198+
199+
// hardcoded ini settings if ZEND_MAX_EXECUTION_TIMERS is disabled
200+
if disableExecutionTimers {
201+
mainThread.phpIni["max_execution_time"] = "0"
202+
mainThread.phpIni["max_input_time"] = "-1"
197203
}
198204

199205
// pass the php.ini overrides to PHP before startup

0 commit comments

Comments
 (0)