diff --git a/main/SAPI.c b/main/SAPI.c index 039ba068270..d1bd3134b6d 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -1073,9 +1073,8 @@ SAPI_API double sapi_get_request_time(void) { if(SG(global_request_time)) return SG(global_request_time); - if (sapi_module.get_request_time && SG(server_context)) { - SG(global_request_time) = sapi_module.get_request_time(); - } else { + if (!sapi_module.get_request_time + || sapi_module.get_request_time(&SG(global_request_time)) == FAILURE) { struct timeval tp = {0}; if (!gettimeofday(&tp, NULL)) { SG(global_request_time) = (double)(tp.tv_sec + tp.tv_usec / 1000000.00); diff --git a/main/SAPI.h b/main/SAPI.h index 97c52c41ecc..77ab84806fe 100644 --- a/main/SAPI.h +++ b/main/SAPI.h @@ -236,7 +236,7 @@ struct _sapi_module_struct { void (*register_server_variables)(zval *track_vars_array); void (*log_message)(const char *message, int syslog_type_int); - double (*get_request_time)(void); + zend_result (*get_request_time)(double *request_time); void (*terminate_process)(void); char *php_ini_path_override; diff --git a/sapi/apache2handler/sapi_apache2.c b/sapi/apache2handler/sapi_apache2.c index 2eeeaf174d8..178b6f3de47 100644 --- a/sapi/apache2handler/sapi_apache2.c +++ b/sapi/apache2handler/sapi_apache2.c @@ -363,10 +363,15 @@ static void php_apache_sapi_log_message_ex(const char *msg, request_rec *r) } } -static double php_apache_sapi_get_request_time(void) +static zend_result php_apache_sapi_get_request_time(double *request_time) { php_struct *ctx = SG(server_context); - return ((double) ctx->r->request_time) / 1000000.0; + if (!ctx) { + return FAILURE; + } + + *request_time = ((double) ctx->r->request_time) / 1000000.0; + return SUCCESS; } extern zend_module_entry php_apache_module;