Skip to content

Commit 4fe2cff

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Prevent error reporting during preloading request start-up
2 parents 9ac998e + c143794 commit 4fe2cff

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4042,16 +4042,30 @@ static int accel_preload(const char *config)
40424042
return ret;
40434043
}
40444044

4045-
size_t preload_ub_write(const char *str, size_t str_length)
4045+
static size_t preload_ub_write(const char *str, size_t str_length)
40464046
{
40474047
return fwrite(str, 1, str_length, stdout);
40484048
}
40494049

4050-
void preload_flush(void *server_context)
4050+
static void preload_flush(void *server_context)
40514051
{
40524052
fflush(stdout);
40534053
}
40544054

4055+
static int preload_header_handler(sapi_header_struct *h, sapi_header_op_enum op, sapi_headers_struct *s)
4056+
{
4057+
return 0;
4058+
}
4059+
4060+
static int preload_send_headers(sapi_headers_struct *sapi_headers)
4061+
{
4062+
return SAPI_HEADER_SENT_SUCCESSFULLY;
4063+
}
4064+
4065+
static void preload_send_header(sapi_header_struct *sapi_header, void *server_context)
4066+
{
4067+
}
4068+
40554069
static int accel_finish_startup(void)
40564070
{
40574071
if (!ZCG(enabled) || !accel_startup_ok) {
@@ -4060,6 +4074,8 @@ static int accel_finish_startup(void)
40604074

40614075
if (ZCG(accel_directives).preload && *ZCG(accel_directives).preload) {
40624076
int ret = SUCCESS;
4077+
int rc;
4078+
int orig_error_reporting;
40634079

40644080
int (*orig_activate)(TSRMLS_D) = sapi_module.activate;
40654081
int (*orig_deactivate)(TSRMLS_D) = sapi_module.deactivate;
@@ -4092,9 +4108,9 @@ static int accel_finish_startup(void)
40924108
sapi_module.activate = NULL;
40934109
sapi_module.deactivate = NULL;
40944110
sapi_module.register_server_variables = NULL;
4095-
sapi_module.header_handler = NULL;
4096-
sapi_module.send_headers = NULL;
4097-
sapi_module.send_header = NULL;
4111+
sapi_module.header_handler = preload_header_handler;
4112+
sapi_module.send_headers = preload_send_headers;
4113+
sapi_module.send_header = preload_send_header;
40984114
sapi_module.getenv = NULL;
40994115
sapi_module.ub_write = preload_ub_write;
41004116
sapi_module.flush = preload_flush;
@@ -4104,7 +4120,15 @@ static int accel_finish_startup(void)
41044120
#ifdef ZEND_SIGNALS
41054121
SIGG(reset) = 0;
41064122
#endif
4107-
if (php_request_startup() == SUCCESS) {
4123+
4124+
orig_error_reporting = EG(error_reporting);
4125+
EG(error_reporting) = 0;
4126+
4127+
rc = php_request_startup();
4128+
4129+
EG(error_reporting) = orig_error_reporting;
4130+
4131+
if (rc == SUCCESS) {
41084132

41094133
/* don't send headers */
41104134
SG(headers_sent) = 1;

0 commit comments

Comments
 (0)