PaulB
Well-known member
- Affected version
- 2.2.12, PHP < 8.2.2
\XF\Entity\User::verifyTimezone
uses the following logic in an attempt to filter out timezones that won't be accepted by DateTimeZone::__construct
:
PHP:
$tzs = \DateTimeZone::listIdentifiers(\DateTimeZone::ALL_WITH_BC);
if (!in_array($timezone, $tzs))
{
$this->error(\XF::phrase('please_select_valid_time_zone'), 'timezone');
return false;
}
Unfortunately,
\DateTimeZone::listIdentifiers
can't be used to get a list of supported timezones. Without the ALL_WITH_BC
flag, acceptable timezones are omitted. With the ALL_WITH_BC
, some acceptable timezones are omitted, while others are returned that can't actually be parsed (https://github.com/php/php-src/issues/10218). This will (probably) be fixed in PHP 8.2.2, but support prior to that is inconsistent, even between PHP revisions: https://3v4l.org/HMcFDA better approach would be to attempt to instantiate
\DateTimeZone
with the provided identifier. If it throws an exception, return false.