Problem/Motivation
Every time I install Drupal8 I get errors relating to default timezones
Proposed resolution
Fix
Remaining tasks
Find out why
User interface changes
No erros on install
API changes
None, yet
When I install I get a timezone warning. This happens when installing with drush si or when installing with the standard profile. My system is php 5.5 nginx and mariadb on osx 10.10.
Attached is the warning from the drush si.
Installation complete. User name: admin User password:******** [ok]
date_default_timezone_get(): 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() [warning]
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\Installer\Form\SiteConfigureForm->buildForm() (line 208 of
core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php).Drupal\Core\Installer\Form\SiteConfigureForm->buildForm(Array, Object, Array)
call_user_func_array(Array, Array)
Drupal\Core\Form\FormBuilder->retrieveForm('install_configure_form', Object)
Drupal\Core\Form\FormBuilder->submitForm('Drupal\Core\Installer\Form\SiteConfigureForm', Object)
install_get_form('Drupal\Core\Installer\Form\SiteConfigureForm', Array)
install_run_task(Array, Array)
install_run_tasks(Array)
install_drupal(Object, Array)
drush_call_user_func_array('install_drupal', Array)
drush_op('install_drupal', Object, Array)
drush_core_site_install_version(NULL, Array)
drush_core_site_install()
call_user_func_array('drush_core_site_install', Array)
_drush_invoke_hooks(Array, Array)
drush_command()
call_user_func_array('drush_command', Array)
drush_dispatch(Array)
Drush\Boot\BaseBoot->bootstrap_and_dispatch()
drush_main()| Comment | File | Size | Author |
|---|---|---|---|
| #5 | drupal-timezone-error-upon-install-complete-2489434-5.patch | 471 bytes | frob |
Comments
Comment #1
alexdmccabehttp://php.net/manual/en/function.date-default-timezone-set.php
This is PHP behavior, not Drupal.
Comment #2
alexdmccabeActually on second thought, Drupal should be handling this by calling date_default_timezone_set(). If it's not, that's a bug.
Comment #3
mikeburrelljr commentedOne option would be to check for date.timezone from the php.ini file during installation, and if not set - inject this into the settings.php file that is created.
Users already select a default timezone during installation, which is used for logged-in users.
We could take this value, and set it in settings.php like so (where 'America/Los_Angeles' is the timezone selected):
Comment #4
frobSounds reasonable. I will have a patch later tonight.
Comment #5
frobI changed the timezone set to UTC and I put this into the install.php and not the settings.php or something else. This issue seems limited to the install script. As such I am changing the component to the install system.
This is the check that needs to happen, however, I wonder it this is a bandaid over a deeper architectural issue with the install system. I will take another look at it later. For now this solves the annoying/confusing warning.
Comment #6
mikeburrelljr commented@frob I've tested your patch, and confirmed it allows a user that doesn't have the timezone set in their php.ini file to get through the installation without issue. However, post-installation, if the user logs-out, they will get an exception for this same issue:
Exception: DateTime::__construct(): 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 DateTime->__construct() (line 226 of core/modules/page_cache/src/StackMiddleware/PageCache.php).While a user should set this value in their php.ini - I can see this confusing to a new user - as it doesn't just show a warning message, but interrupts the entire loading of the site due to an exception.
Recommendation:
Comment #7
cilefen commentedThank you for reporting this issue. It is a duplicate of #2446859: Installer warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings.