Post by franklinveaux » Fri Feb 26, 2021 12:37 pm

I've just run into a problem with a brand new OpenCart 3.0.3.7 install.

The stats: OpenCart 3.0.3.7, completely stock install on a Dreamhost VPS with PHP 7.3, no extensions, default template.

I've run into this problem multiple times and it's 100% repeatable. Install OpenCart. Create an administrator during the install. Log on once the install is done. Go to store settings. Change the time zone from the default to America/Los Angeles.

Boom. Instantly on hitting Save, you'll be taken to the Login screen. From that point on, you can never log in to the administrator dashboard again. Typing a valid administrator username and password silently takes you back to the login screen.

Tested multiple times with Chrome, Firefox, and Safari.

Newbie

Posts

Joined
Tue Feb 21, 2017 12:42 pm

Post by sw!tch » Sat Feb 27, 2021 8:32 am

Already been reported, https://github.com/opencart/opencart/issues/9237

If locked out you can find a temp workaround below or otherwise wait for an official fix -
viewtopic.php?f=201&t=222369#p813699

Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by straightlight » Mon Mar 01, 2021 7:35 am

See if this workaround resolves the issue: viewtopic.php?f=201&t=222369#p813324 .

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Ravenfire » Wed May 19, 2021 9:28 am

The workaround does re-enable the login, however, the wrong Timezone is a real issue when dealing with Sales (as well as logs, etc).

Is there a proper fix available yet ???

Thanks in Advance.

Newbie

Posts

Joined
Wed May 19, 2021 9:25 am

Post by ADD Creative » Wed May 19, 2021 4:42 pm

As stated in viewtopic.php?f=201&t=222369&start=20#p816440. You can change date_timezone in system/config/default.php timezone to match what you selected in store settings. https://github.com/opencart/opencart/bl ... lt.php#L14

Or try https://github.com/opencart/opencart/pull/9633.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by jc3dev » Mon Jul 05, 2021 4:32 am

If you look the file "system/framework.php." When set de default timezone for php (line 15) it take value from the file "system/config/default.php" and not from the database setting configuration (if is different show the error). The quick solution is changing the value from default.php file but if you change on setting page you'll need update this file again.

Another solution is changing the order of code in "system/framework.php" (until official fix). This is what I do:
// replece the line 15
date_default_timezone_set($config->get('date_timezone'));
// with this code:
// Sync PHP and DB time zones
if ($config->get('db_autostart')) {
$db = new DB($config->get('db_engine'), $config->get('db_hostname'), $config->get('db_username'), $config->get('db_password'), $config->get('db_database'), $config->get('db_port'));
$registry->set('db', $db);

$query = $db->query("SELECT value FROM " . DB_PREFIX . "setting WHERE `code` = 'config' AND `key` = 'config_timezone' ");

if (!empty($query->row)) {
$timezone = $query->row['value'];
date_default_timezone_set($timezone);
} else {
date_default_timezone_set($config->get('date_timezone'));
}
$db->query("SET time_zone = '" . $db->escape(date('P')) . "'");

} else {
date_default_timezone_set($config->get('date_timezone'));
}

// comment or delete this lines because is not usefull (included on solution before) start on line 78, finish on 85
// Database
if ($config->get('db_autostart')) {
$db = new DB($config->get('db_engine'), $config->get('db_hostname'), $config->get('db_username'), $config->get('db_password'), $config->get('db_database'), $config->get('db_port'));
$registry->set('db', $db);

// Sync PHP and DB time zones
$db->query("SET time_zone = '" . $db->escape(date('P')) . "'");
}

Newbie

Posts

Joined
Mon Jul 05, 2021 3:52 am

Post by straightlight » Mon Jul 05, 2021 4:55 pm

Code: Select all

$query = $db->query("SELECT value FROM " . DB_PREFIX . "setting WHERE `code` = 'config' AND `key` = 'config_timezone' ");
with:

Code: Select all

$query = $db->query("SELECT `value` FROM `" . DB_PREFIX . "setting` WHERE `code` = 'config' AND `key` = 'config_timezone' ");

Code: Select all

if (!empty($query->row)) {
with:

Code: Select all

if ($query->num_rows) {

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 95 guests