From 12f83c0e86da919b41bb5c0640863966905d40ba Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Thu, 26 Apr 2018 14:19:43 -0700 Subject: [PATCH] Fixed #2761 --- CHANGELOG-v3.md | 1 + src/console/Application.php | 9 ++++----- src/web/Application.php | 6 ++++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG-v3.md b/CHANGELOG-v3.md index ba0c979d976..2e69a8ab8b7 100644 --- a/CHANGELOG-v3.md +++ b/CHANGELOG-v3.md @@ -10,6 +10,7 @@ ### Fixed - Fixed an error that would occur on servers without the Phar PHP extension enabled. - Fixed an error that could occur if a Matrix block was deleted by a queue job. ([#2813](https://github.com/craftcms/cms/issues/2813)) +- Fixed a bug where Twig could be configured to output times in UTC rather than the system timezone, if a bootstrapped module was loading Twig. ([#2761](https://github.com/craftcms/cms/issues/2761)) ## 3.0.4 - 2018-04-24 diff --git a/src/console/Application.php b/src/console/Application.php index 563d9a098da..447ccd7506a 100644 --- a/src/console/Application.php +++ b/src/console/Application.php @@ -53,12 +53,11 @@ public function __construct($config = []) */ public function init() { - parent::init(); - - // Set default timezone to UTC - date_default_timezone_set('UTC'); - + $this->state = self::STATE_INIT; + // Important that we call $this->_init() before parent::init(), so that it's run before bootstrap() + // in case bootstrap() ends up loading a module that loads Twig, configuring Twig with the wrong timezone $this->_init(); + parent::init(); } /** diff --git a/src/web/Application.php b/src/web/Application.php index aa2f420da02..e7b51d6ffdc 100644 --- a/src/web/Application.php +++ b/src/web/Application.php @@ -93,9 +93,11 @@ public function __construct(array $config = []) */ public function init() { - parent::init(); - + $this->state = self::STATE_INIT; + // Important that we call $this->_init() before parent::init(), so that it's run before bootstrap() + // in case bootstrap() ends up loading a module that loads Twig, configuring Twig with the wrong timezone $this->_init(); + parent::init(); $this->ensureResourcePathExists(); $this->debugBootstrap(); }