Description
Opening Web → PHP Pools for a site whose active PHP-FPM pool has OPcache disabled (opcache_enabled: false, e.g., MultiPHP 8.3 running WHMCS/ionCube) throws a 500 Internal Server Error (Division by zero).
Error
(Illuminate\View\ViewException) EXCEPTION: Division by zero (View: /usr/local/apnscp/apps/php-pools/views/partials/cache-metrics.blade.php)
Root Cause
php:pool-cache-status still returns directives from opcache_get_configuration() even when opcache_enabled is false and opcache_statistics.hits / misses are both 0:
opcache_enabled: false
opcache_statistics:
hits: 0
misses: 0
Because apps/php-pools/views/partials/perf-data.blade.php (line 35) only checks:
@if (isset($metrics['directives']))
@include('partials.cache-metrics')
it renders apps/php-pools/views/partials/cache-metrics.blade.php, which divides directly by (hits + misses) (line 22) without guarding against 0, causing a PHP 8 DivisionByZeroError.
Suggested Fix
Either check !empty($metrics['opcache_enabled']) in perf-data.blade.php before including partials.cache-metrics, and/or guard the denominators in cache-metrics.blade.php (e.g., ?: 1 on hits + misses, REQUEST_TIME - start_time, and opcache.memory_consumption).
Environment
- ApisCP commit:
cefa24236 - PHP-FPM: MultiPHP 8.3 with
opcache_enabled: false