Skip to content

Commit 9bea5f4

Browse files
Mikhail Galanindevnexen
Mikhail Galanin
authored andcommitted
Add "Start time", "Last restart time" and "Last force restart time" to phpinfo()
for opcache. Closes GH-9475.
1 parent ebc4159 commit 9bea5f4

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 8.3.0alpha1
44

5+
- Opcache:
6+
. Added start, restart and force restart time to opcache's
7+
phpinfo section. (Mikhail Galanin)
8+
59
- Posix:
610
. Added posix_sysconf. (David Carlier)
711

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
@@ -481,6 +482,9 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS)
481482
php_info_print_table_row(2, "Startup Failed", zps_api_failure_reason);
482483
} else {
483484
char buf[32];
485+
zend_string *start_time, *restart_time, *force_restart_time;
486+
zval *date_ISO8601 = zend_get_constant_str("DATE_ISO8601", sizeof("DATE_ISO8601")-1);
487+
484488
php_info_print_table_row(2, "Startup", "OK");
485489
php_info_print_table_row(2, "Shared memory model", zend_accel_get_shared_model());
486490
snprintf(buf, sizeof(buf), ZEND_ULONG_FMT, ZCSG(hits));
@@ -511,6 +515,26 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS)
511515
php_info_print_table_row(2, "Hash keys restarts", buf);
512516
snprintf(buf, sizeof(buf), ZEND_ULONG_FMT, ZCSG(manual_restarts));
513517
php_info_print_table_row(2, "Manual restarts", buf);
518+
519+
start_time = php_format_date(Z_STRVAL_P(date_ISO8601), Z_STRLEN_P(date_ISO8601), ZCSG(start_time), 1);
520+
php_info_print_table_row(2, "Start time", ZSTR_VAL(start_time));
521+
zend_string_release(start_time);
522+
523+
if (ZCSG(last_restart_time)) {
524+
restart_time = php_format_date(Z_STRVAL_P(date_ISO8601), Z_STRLEN_P(date_ISO8601), ZCSG(last_restart_time), 1);
525+
php_info_print_table_row(2, "Last restart time", ZSTR_VAL(restart_time));
526+
zend_string_release(restart_time);
527+
} else {
528+
php_info_print_table_row(2, "Last restart time", "none");
529+
}
530+
531+
if (ZCSG(force_restart_time)) {
532+
force_restart_time = php_format_date(Z_STRVAL_P(date_ISO8601), Z_STRLEN_P(date_ISO8601), ZCSG(force_restart_time), 1);
533+
php_info_print_table_row(2, "Last force restart time", ZSTR_VAL(force_restart_time));
534+
zend_string_release(force_restart_time);
535+
} else {
536+
php_info_print_table_row(2, "Last force restart time", "none");
537+
}
514538
}
515539
}
516540

0 commit comments

Comments
 (0)