Skip to content

Commit f361b07

Browse files
committed
use hardcoded ini like CLI
1 parent 864a08d commit f361b07

1 file changed

Lines changed: 24 additions & 5 deletions

File tree

sapi/embed/php_embed.c

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@
2424
#include <fcntl.h>
2525
#endif
2626

27+
#define HARDCODED_INI \
28+
"html_errors=0\n" \
29+
"register_argc_argv=1\n" \
30+
"implicit_flush=1\n" \
31+
"output_buffering=0\n" \
32+
"max_execution_time=0\n" \
33+
"max_input_time=-1\n"
34+
2735
static char* php_embed_read_cookies(TSRMLS_D)
2836
{
2937
return NULL;
@@ -141,6 +149,7 @@ int php_embed_init(int argc, char **argv PTSRMLS_DC)
141149
sapi_globals_struct *sapi_globals;
142150
void ***tsrm_ls;
143151
#endif
152+
int ini_entries_len = 0;
144153

145154
#ifdef HAVE_SIGNAL_H
146155
#if defined(SIGPIPE) && defined(SIG_IGN)
@@ -173,6 +182,11 @@ int php_embed_init(int argc, char **argv PTSRMLS_DC)
173182
*ptsrm_ls = tsrm_ls;
174183
#endif
175184

185+
ini_entries_len = strlen(HARDCODED_INI);
186+
php_embed_module.ini_entries = malloc(ini_entries_len+2);
187+
memcpy(php_embed_module.ini_entries, HARDCODED_INI, ini_entries_len+1);
188+
php_embed_module.ini_entries[ini_entries_len+1] = 0;
189+
176190
sapi_startup(&php_embed_module);
177191

178192
if (php_embed_module.startup(&php_embed_module)==FAILURE) {
@@ -187,11 +201,12 @@ int php_embed_init(int argc, char **argv PTSRMLS_DC)
187201

188202
/* Set some Embedded PHP defaults */
189203
SG(options) |= SAPI_OPTION_NO_CHDIR;
190-
zend_alter_ini_entry("register_argc_argv", 19, "1", 1, PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
191-
zend_alter_ini_entry("html_errors", 12, "0", 1, PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
192-
zend_alter_ini_entry("implicit_flush", 15, "1", 1, PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
193-
zend_alter_ini_entry("max_execution_time", 19, "0", 1, PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
194-
204+
#if 0
205+
// zend_alter_ini_entry("register_argc_argv", 19, "1", 1, PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
206+
// zend_alter_ini_entry("html_errors", 12, "0", 1, PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
207+
// zend_alter_ini_entry("implicit_flush", 15, "1", 1, PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
208+
// zend_alter_ini_entry("max_execution_time", 19, "0", 1, PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
209+
#endif
195210
SG(request_info).argc=argc;
196211
SG(request_info).argv=argv;
197212

@@ -215,6 +230,10 @@ void php_embed_shutdown(TSRMLS_D)
215230
#ifdef ZTS
216231
tsrm_shutdown();
217232
#endif
233+
if (php_embed_module.ini_entries) {
234+
free(php_embed_module.ini_entries);
235+
php_embed_module.ini_entries = NULL;
236+
}
218237
}
219238

220239
/*

0 commit comments

Comments
 (0)