amnuts / opcache-gui

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

PHP 8.0 compatibility issues #77

Closed reteP-riS closed 2 years ago

reteP-riS commented 2 years ago

With PHP 8.0 the "Overview" tab throws this date() function related warning:

Strict Standards: date(): We selected 'Europe/Berlin' for 'CET/1.0/no DST' instead in /REDACTED/index.php on line 343

A "Reset cache" throws:

Strict Standards: date(): We selected 'Europe/Berlin' for 'CET/1.0/no DST' instead in /REDACTED/index.php on line 343
Strict Standards: date(): We selected 'Europe/Berlin' for 'CET/1.0/no DST' instead in /REDACTED/index.php on line 343
Warning: Cannot modify header information - headers already sent by (output started at /REDACTED/index.php:343) in /REDACTED/index.php on line 163
amnuts commented 2 years ago

@reteP-riS, see if this branch helps to fix these issues: https://github.com/amnuts/opcache-gui/tree/php8-strict-date-fixes

reteP-riS commented 2 years ago

Thanks for looking into this, but with PHP 8.0 the "Overview" tab now throws additional messages for DateTimeImmutable:

Strict Standards: DateTimeImmutable::__construct(): We selected 'Europe/Berlin' for 'CET/1.0/no DST' instead in /REDACTED/index.php on line 349
Strict Standards: date_default_timezone_get(): We selected 'Europe/Berlin' for 'CET/1.0/no DST' instead in /REDACTED/index.php on line 350

while a "Reset cache" throws:

Strict Standards: DateTimeImmutable::__construct(): We selected 'Europe/Berlin' for 'CET/1.0/no DST' instead in /REDACTED/index.php on line 349
Strict Standards: date_default_timezone_get(): We selected 'Europe/Berlin' for 'CET/1.0/no DST' instead in /REDACTED/index.php on line 350
Strict Standards: DateTimeImmutable::__construct(): We selected 'Europe/Berlin' for 'CET/1.0/no DST' instead in /REDACTED/index.php on line 349
Strict Standards: date_default_timezone_get(): We selected 'Europe/Berlin' for 'CET/1.0/no DST' instead in /REDACTED/index.php on line 350
Warning: Cannot modify header information - headers already sent by (output started at /REDACTED/index.php:349) in /REDACTED/index.php on line 168
reteP-riS commented 2 years ago

The behaviour is documented at https://www.php.net/manual/en/function.date-default-timezone-get.php

It seems that my hosting provider forgot to set the timezone default for PHP 8.0. After adding date.timezone=Europe/Berlin to my php.ini all these error messages are gone, but maybe you can add a timezone option to the user configuration section at the top of index.php defaulting to UTC and use the date_default_timezone_set() function to set the default accordingly.

I would expect others with a missing timezone default to observe the same behaviour, but this might require to add something like this to the phi.ini file.

; Set the error reporting level.
error_reporting=E_ALL|E_STRICT

; Whether errors should be logged to file.
log_errors=On
; Name of the file where errors should be logged.
error_log=/REDACTED/php-error.log

; Whether errors should be printed to the screen.
display_errors=On