Fixed Exception: DateTimeZone::__construct(): Unknown or bad timezone () src/addons/XFI/Import/Importer/Discourse.php:613

Fajfie

Member
Affected version
2.2.7
Discourse import error:

Code:
#0 src/addons/XFI/Import/Importer/Discourse.php(613): DateTimeZone->__construct('')
#1 src/XF/Import/Runner.php(244): XFI\Import\Importer\Discourse->stepUsers(Object(XF\Import\StepState), Array, 8)
#2 src/XF/Import/Runner.php(61): XF\Import\Runner->runStep('users', Object(XF\Import\StepState), 8)
#3 src/XF/Admin/Controller/Import.php(234): XF\Import\Runner->run()
#4 src/XF/Mvc/Dispatcher.php(352): XF\Admin\Controller\Import->actionRun(Object(XF\Mvc\ParameterBag))
#5 src/XF/Mvc/Dispatcher.php(259): XF\Mvc\Dispatcher->dispatchClass('XF:Import', 'Run', Object(XF\Mvc\RouteMatch), Object(XF\Admin\Controller\Import), NULL)
#6 src/XF/Mvc/Dispatcher.php(115): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(XF\Admin\Controller\Import), NULL)
#7 src/XF/Mvc/Dispatcher.php(57): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#8 src/XF/App.php(2345): XF\Mvc\Dispatcher->run()
#9 src/XF.php(512): XF\App->run()
#10 admin.php(13): XF::runApp('XF\\Admin\\App')
#11 {main}

Code:
array(4) {
  ["url"] => string(21) "/admin.php?import/run"
  ["referrer"] => string(43) "XXX/admin.php?import/"
  ["_GET"] => array(1) {
    ["import/run"] => string(0) ""
  }
  ["_POST"] => array(1) {
    ["_xfToken"] => string(8) "********"
  }
}
 
This should sort this one:

Diff:
diff --git a/src/addons/XFI/Import/Importer/Discourse.php b/src/addons/XFI/Import/Importer/Discourse.php
index 81de43269c..5634819a1b 100644
--- a/src/addons/XFI/Import/Importer/Discourse.php
+++ b/src/addons/XFI/Import/Importer/Discourse.php
@@ -610,7 +610,7 @@ public function stepUsers(
                 'custom_title' => 'title'
             ]);
 
-            $timezone = new \DateTimeZone($user['timezone']);
+            $timezone = new \DateTimeZone($user['timezone'] ?: 'Europe/London');
             $userData['timezone'] = $this->getTimezoneFromOffset(
                 $timezone->getOffset(\DateTime::createFromFormat('U', 0)) / 3600,
                 true
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XFI release (1.5.2).

Change log:
Fallback to the default time zone when importing Discourse users with no time zone set
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom