From 828d70cdd140c47f8c17da84a26c79a5ee915d22 Mon Sep 17 00:00:00 2001 From: Andrey Savchenko Date: Tue, 22 Jan 2019 16:27:38 +0200 Subject: [PATCH] Added PHP version and OPcache status information. --- CHANGELOG.md | 1 + src/Record/Collector/Core_Load_Collector.php | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dbd195..0214e0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added - WooCommerce events +- PHP version and OPcache status information ### Fixed - headers error from new line in Server Timing diff --git a/src/Record/Collector/Core_Load_Collector.php b/src/Record/Collector/Core_Load_Collector.php index 7076ee9..bb5886b 100644 --- a/src/Record/Collector/Core_Load_Collector.php +++ b/src/Record/Collector/Core_Load_Collector.php @@ -30,12 +30,19 @@ class Core_Load_Collector implements Record_Collector_Interface { $request_time = filter_var( $_SERVER['REQUEST_TIME_FLOAT'], FILTER_VALIDATE_FLOAT ); + $php = 'PHP Load – ' . PHP_VERSION; + + if ( function_exists( 'opcache_get_status' ) ) { + $zend_status = opcache_get_status(); + $php .= empty( $zend_status['opcache_enabled'] ) ? '' : ' – OPcache'; + } + /** * @var float $request_time * @var float $timestart */ return [ - new Record( 'PHP Load', $request_time, $timestart - $request_time, '', 'php' ), + new Record( $php, $request_time, $timestart - $request_time, '', 'php' ), // TODO This includes network plugins on multisite, need conditional label if Laps is network–activated. new Record( 'Core and MU Plugins Load', $timestart, $this->timeload - $timestart, '', 'core' ), ];