From 8d47db39cf43b9a854a05c122dab6bbbf4424344 Mon Sep 17 00:00:00 2001 From: Alexander Bias Date: Wed, 21 Aug 2024 12:39:40 +0200 Subject: [PATCH] Upgrade OPcache GUI to version 3.5.5 --- CHANGES.md | 4 +++ UPGRADE.md | 10 ++++-- lib/opcache-gui/index.php.inc | 63 ++++++++++++++++++++++++++--------- 3 files changed, 60 insertions(+), 17 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 14795a0..03923bb 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,10 @@ moodle-tool_opcache Changes ------- +### Unreleased + +* 2024-08-21 - Upgrade OPcache GUI to version 3.5.5 + ### v4.2-r2 * 2024-08-11 - Add section for scheduled tasks to README diff --git a/UPGRADE.md b/UPGRADE.md index 7b3259b..8bf594f 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -15,8 +15,14 @@ Upstream changes ---------------- * This plugin relies on the thiry-party Opcache-GUI tool which is located within the plugin directory. This tool is under active development and has to be updated within the plugin every now and then. -* Basically, you will just need to take the index.php file from the Opcache-GUI repo on https://github.com/amnuts/opcache-gui and replace the /lib/opcache-gui/index.php.inc file with this new version. -* However, as we want to use a CDN-less version of Opcache-GUI, you will have to rebuild the software according to https://github.com/amnuts/opcache-gui#the-javascript. +* Basically, you would just need to take the index.php file from the Opcache-GUI repo on https://github.com/amnuts/opcache-gui and replace the /lib/opcache-gui/index.php.inc file with this new version. +* However, as we want to use a CDN-less version of Opcache-GUI, you will have to rebuild the software according to https://github.com/amnuts/opcache-gui#the-javascript. Generally, it works like this: +``` + git clone git@github.com:amnuts/opcache-gui.git + cd opcache-gui + php ./build/build.php --local-js + cp index.php /lib/opcache-gui/index.php.inc +``` Automated tests diff --git a/lib/opcache-gui/index.php.inc b/lib/opcache-gui/index.php.inc index 8171b77..bddd6b3 100644 --- a/lib/opcache-gui/index.php.inc +++ b/lib/opcache-gui/index.php.inc @@ -6,7 +6,7 @@ * A simple but effective single-file GUI for the OPcache PHP extension. * * @author Andrew Collington, andy@amnuts.com - * @version 3.5.2 + * @version 3.5.5 * @link https://github.com/amnuts/opcache-gui * @license MIT, https://acollington.mit-license.org/ */ @@ -59,7 +59,7 @@ header('Pragma: no-cache'); class Service { - public const VERSION = '3.5.2'; + public const VERSION = '3.5.5'; protected $tz; protected $data; @@ -417,7 +417,7 @@ class Service ]; } - if ($overview && !empty($status['jit'])) { + if ($overview && !empty($status['jit']['enabled'])) { $overview['jit_buffer_used_percentage'] = ($status['jit']['buffer_size'] ? round(100 * (($status['jit']['buffer_size'] - $status['jit']['buffer_free']) / $status['jit']['buffer_size'])) : 0 @@ -488,9 +488,30 @@ class Service 'preload' => $preload, 'directives' => $directives, 'blacklist' => $config['blacklist'], - 'functions' => get_extension_funcs('Zend OPcache') + 'functions' => get_extension_funcs('Zend OPcache'), + 'jitState' => $this->jitState($status, $config['directives']), ]; } + + protected function jitState(array $status, array $directives): array + { + $state = [ + 'enabled' => $status['jit']['enabled'], + 'reason' => '' + ]; + + if (!$state['enabled']) { + if (empty($directives['opcache.jit']) || $directives['opcache.jit'] === 'disable') { + $state['reason'] = $this->txt('disabled due to opcache.jit setting'); + } elseif (!$directives['opcache.jit_buffer_size']) { + $state['reason'] = $this->txt('the opcache.jit_buffer_size must be set to fully enable JIT'); + } else { + $state['reason'] = $this->txt('incompatible with extensions that override zend_execute_ex(), such as xdebug'); + } + } + + return $state; + } } $opcache = (new Service($options))->handle(); @@ -821,10 +842,10 @@ function(a,b,c){if(!Vd(b))throw Error(n(200));return Wd(null,a,b,!1,c)};Q.unmoun