amnuts / opcache-gui

A clean, effective and responsive interface for Zend OPcache
1.21k stars 197 forks source link

Undefined index: memory_usage on line 191 #44

Closed ASchmidt1 closed 4 years ago

ASchmidt1 commented 4 years ago

The following line only catches the scenario, if the memory cache was disabled explicitly via settings:

        if ($config['directives']['opcache.file_cache_only']) {
            $overview = false;

However, it fails to catch the scenario where the memory cache is dynamically disabled due to file cache fall-back. These settings were active:

opcache.file_cache_fallback = 1 opcache.file_cache_only = 0

and during startup, OpCache triggered the fallback with the message: "Warning Opcode handlers are unusable due to ASLR (fall-back to file cache)"

In that case, the $status only contains:

array (size=3)
  'opcache_enabled' => boolean false
  'file_cache' => string 'C:\Windows\Temp\PHP\OpCache' (length=27)
  'file_cache_only' => boolean true

FIX By also checking the $status['file_cache_only'], the GUI will proceed correctly:

        if ($config['directives']['opcache.file_cache_only'] or !empty( $status['file_cache_only'] ) ) {
            $overview = false;
amnuts commented 4 years ago

Thanks for reporting @ASchmidt1. I'm not able to fix this myself for the next week or so, but if you want to submit a PR please feel free.