View Issue Details

IDProjectCategoryView StatusLast Update
0027796mantisbtinstallationpublic2020-12-30 05:40
Reporterdregad Assigned Todregad  
Status resolvedResolutionfixed 
Target Version2.25.0Fixed in Version2.25.0 
Summary0027796: Using an empty timezone causes PHP notice on PHP 8

When $g_default_timezone is empty (which is the default setting in config_defaults_inc.php), on PHP 8 systems Mantis throws
SYSTEM NOTICE: 'date_default_timezone_set(): Timezone ID '' is invalid' in '/path/to/mantisbt/core.php' line 273

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.

TagsPHP 8


related to 0027799 closeddregad Adapt Error handler to PHP 8 




2020-12-24 05:38

developer   ~0064838

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: 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 @ operator...

[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.



2020-12-24 07:25

developer   ~0064841




2020-12-24 07:40

developer   ~0064842

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.

Related Changesets

MantisBT: master de1679d5

2020-12-23 12:57:58


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

Affected Issues
mod - core.php Diff File

MantisBT: master 328f2208

2020-12-24 10:10:21


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
mod - admin/install.php Diff File