Problem/Motivation

When user not logged in, there is a warning: (drupal8-beta9)
Warning: DateTime::createFromFormat(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in Drupal\Core\EventSubscriber\FinishResponseSubscriber->setExpiresNoCache() (line 252 of core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php).

Proposed resolution

Hide the warning.

Reference, for valid/invalid timezones:
http://php.net/manual/en/timezones.others.php

Remaining tasks

Review patch, or find a better solution to fix this issue.

User interface changes

None.

API changes

None.

CommentFileSizeAuthor
#3 default_timezone-2471405-3.patch719 bytestompagabor

Comments

tompagabor’s picture

Issue summary: View changes
tompagabor’s picture

Issue summary: View changes
tompagabor’s picture

Status: Active » Needs review
StatusFileSize
new719 bytes

Maybe enough to change GMT to UTC.
Please review.

gaëlg’s picture

Status: Needs review » Reviewed & tested by the community

Last patch removed the warning from my local install.

  • alexpott committed 3684dd2 on 8.0.x
    Issue #2471405 by tompagabor: When not logged Drupal\Core\...
alexpott’s picture

Title: when not logged in Drupal\Core\EventSubscriber\FinishResponseSubscriber->setExpiresNoCache() runs error, because not set valid timezone » When not logged Drupal\Core\EventSubscriber\FinishResponseSubscriber->setExpiresNoCache() causes a PHP warning because of an invalid timezone
Status: Reviewed & tested by the community » Fixed

Makes sense. This issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed 3684dd2 and pushed to 8.0.x. Thanks!

znerol’s picture

I think the warning message has been misinterpreted in that case. This warning is triggered if the date.timezone ini value is not configured and if date_default_timezone_set() has not been called before any date/time format function.

We call date_default_timezone_set() from within AccountProxy::setAccount. This changed in #2328645: Remove remaining global $user, before we called that function always from within SessionManager::start(). Also note that since #2228393: Decouple session from cookie based user authentication we do not call AccountProxy::setAccount() for anonymous users anymore.

Please note that you get this warning if your PHP environment is not properly configured. This is not something which could be fixed in Drupal. Also note that specifying UTC instead of GMT is not allowed in HTTP header timestamps (see also #1918820: HTTP header date formats). I guess that the Symfony response will take care and reformat that properly before it is sent to the client.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.