Allow get_request_time() hook to fail

In particular, this allows using the hook without server_context.
The apache2handler implementation now checks that server_context
is available itself, as that's the implementation that cares
about it.
This commit is contained in:
Nikita Popov 2021-09-16 16:54:07 +02:00
parent 13fa90fb55
commit e2d05bfcb2
3 changed files with 10 additions and 6 deletions

View file

@ -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;