Skip to content

Commit 996a4e3

Browse files
author
Mikhail Galanin
committed
Add "Start time" and "Last restart time" to phpinfo() for opcache
1 parent e2bdf4d commit 996a4e3

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

ext/opcache/zend_accelerator_module.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "zend_virtual_cwd.h"
3232
#include "ext/standard/info.h"
3333
#include "ext/standard/php_filestat.h"
34+
#include "ext/date/php_date.h"
3435
#include "opcache_arginfo.h"
3536

3637
#if HAVE_JIT
@@ -461,6 +462,9 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS)
461462
php_info_print_table_row(2, "Startup Failed", zps_api_failure_reason);
462463
} else {
463464
char buf[32];
465+
zend_string *start_time, *restart_time, *force_restart_time;
466+
zval *date_ISO8601 = zend_get_constant_str("DATE_ISO8601", sizeof("DATE_ISO8601")-1);
467+
464468
php_info_print_table_row(2, "Startup", "OK");
465469
php_info_print_table_row(2, "Shared memory model", zend_accel_get_shared_model());
466470
snprintf(buf, sizeof(buf), ZEND_ULONG_FMT, ZCSG(hits));
@@ -491,6 +495,26 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS)
491495
php_info_print_table_row(2, "Hash keys restarts", buf);
492496
snprintf(buf, sizeof(buf), ZEND_ULONG_FMT, ZCSG(manual_restarts));
493497
php_info_print_table_row(2, "Manual restarts", buf);
498+
499+
start_time = php_format_date(Z_STRVAL_P(date_ISO8601), Z_STRLEN_P(date_ISO8601), ZCSG(start_time), 1);
500+
php_info_print_table_row(2, "Start time", ZSTR_VAL(start_time));
501+
zend_string_release(start_time);
502+
503+
if (ZCSG(last_restart_time)) {
504+
restart_time = php_format_date(Z_STRVAL_P(date_ISO8601), Z_STRLEN_P(date_ISO8601), ZCSG(last_restart_time), 1);
505+
php_info_print_table_row(2, "Last restart time", ZSTR_VAL(restart_time));
506+
zend_string_release(restart_time);
507+
} else {
508+
php_info_print_table_row(2, "Last restart time", "none");
509+
}
510+
511+
if (ZCSG(force_restart_time)) {
512+
force_restart_time = php_format_date(Z_STRVAL_P(date_ISO8601), Z_STRLEN_P(date_ISO8601), ZCSG(force_restart_time), 1);
513+
php_info_print_table_row(2, "Last force restart time", ZSTR_VAL(force_restart_time));
514+
zend_string_release(force_restart_time);
515+
} else {
516+
php_info_print_table_row(2, "Last force restart time", "none");
517+
}
494518
}
495519
}
496520

0 commit comments

Comments
 (0)