View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0027796 | mantisbt | installation | public | 2020-12-23 12:42 | 2021-03-07 18:28 |
Reporter | dregad | Assigned To | dregad | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Target Version | 2.25.0 | Fixed in Version | 2.25.0 | ||
Summary | 0027796: Using an empty timezone causes PHP notice on PHP 8 | ||||
Description | When $g_default_timezone is empty (which is the default setting in config_defaults_inc.php), on PHP 8 systems Mantis throws The default time zone is usually set by the installer and saved in config_inc.php, so this should not affect existing installations, but can easily be reproduced when installing Mantis (install.php) or by removing the $g_default_timezone option from the config file. Everything else being equal, problem does not occur on PHP 7.4. | ||||
Tags | PHP 8 | ||||
It seems that the error suppression operator is not doing its job... After research, this is caused by the value of error_reporting being 4437 within our error handler, instead of 0 as expected [1] on PHP 8.0.0 (with PHP 7.4.13, we do get the expected value of 0). This causes it not to abort I submitted a PHP bug: https://bugs.php.net/bug.php?id=80548. Not sure if it's an actual bug or just a documentation issue. In the meanwhile, this may be the time to get rid of this usage of [1] Documentation for set_error_handler states current value of error_reporting [...] will be 0 if the statement that caused the error was prepended by the @ error-control operator. |
|
So as it turns out, the change in behavior is intended, as per PHP 8.0 migration guide The @ operator will no longer silence fatal errors (E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR, E_PARSE). Error handlers that expect error_reporting to be 0 when @ is used, should be adjusted to use a mask check instead I opened 0027799 to track the required adjustment to the error handler. |
|
MantisBT: master de1679d5 2020-12-23 07:57 Details Diff |
Improve timezone setting logic Previously, core.php tried to set the default timezone to the value stored in global configuration, with error suppression. Due to [[1]], this does not actually prevent the notice from appearing with PHP 8. Refactored the code to get the system's default time zone if it is not defined in configuration. A PHP notice is still thrown if the specified timezone is not valid, as documented in the code. Also, since PHP 5.4, date_default_timezone_get() no longer throws a warning so the '@' operator is not needed anymore. Fixes 0027796 [1]: https://bugs.php.net/bug.php?id=80548 |
Affected Issues 0027796 |
|
mod - core.php | Diff File | ||
MantisBT: master 328f2208 2020-12-24 05:10 Details Diff |
Prevent system warning when creating config_inc.php Due to the same root cause as issue 0027796, the `@` operator does not suppress the error. Instead of suppressing the error, check whether the parent directory is writable before calling fopen(). |
Affected Issues 0027796 |
|
mod - admin/install.php | Diff File |