Page 1 of 4

[SOLUTION] OC 3.0.3.7 Timezone Issue

Posted: Fri Feb 05, 2021 11:34 am
by vthompson
I just installed ver 3.0.3.7 and going through editing the store details

System -> Settings -> Store -> Local -> Time Zone

I set the time zone to America/Detroit (-5:00) and was unable to login. I found several posts which addressed this issue, but the one which worked was changing the session engine from db to file in the system/config/default.php and system/config/catalog.php files.

Perhaps this is telling me I need to set the time zone to match somewhere else, but it would be nice if there was a heads up that this result is a possibility, even a check during the initial pre-install list.

Re: OC 3.0.3.6 Timezone Issue

Posted: Fri Feb 05, 2021 6:23 pm
by sw!tch
You sure you installed 3.0.3.6 ? As far as I know there is no timezone setting by default in 3.0.3.6.

Re: OC 3.0.3.6 Timezone Issue

Posted: Sat Feb 06, 2021 1:04 pm
by vthompson
sw!tch wrote:
Fri Feb 05, 2021 6:23 pm
You sure you installed 3.0.3.6 ? As far as I know there is no timezone setting by default in 3.0.3.6.
I said "I set the timezone". No, it is not set by default.

Re: OC 3.0.3.6 Timezone Issue

Posted: Sat Feb 06, 2021 1:20 pm
by Majnoon
vthompson wrote:
Sat Feb 06, 2021 1:04 pm
No, it is not set by default.
How did you got that option there? Because as per Switch comments there is no default option for that.
Have you installed some extension or m modified the core code etc?

Re: OC 3.0.3.6 Timezone Issue

Posted: Sat Feb 06, 2021 1:40 pm
by vthompson
Majnoon wrote:
Sat Feb 06, 2021 1:20 pm
vthompson wrote:
Sat Feb 06, 2021 1:04 pm
No, it is not set by default.
How did you got that option there? Because as per Switch comments there is no default option for that.
Have you installed some extension or m modified the core code etc?
I'm sorry but I feel like my original post is not being read. I literally posted how I got there. I was going through the settings and figured setting the timezone would be a fine thing to do. Once I set it and saved, I was logged out and had no way to get back to normal, short of wiping and starting over. I posted how it was solved and thoughts on preventing others from doing it. Searching shows other people have encountered the issue too. It's been ongoing for several versions at least.

Re: OC 3.0.3.6 Timezone Issue

Posted: Sat Feb 06, 2021 1:55 pm
by by mona
You post has been read and understood by 3 people.
However the part that you are not understanding is there is no place to set the timezone in Opencart to best of our knowledge. If you know better please send a screenshot.
There is also no System -> Settings -> Store -> Local -> Time Zone -
There is System -> Settings -> Store and there is System -> Settings -> Local

This is not a bug, at least not in Opencart, but we do thank you for assisting someone - we are just not sure who.

Re: OC 3.0.3.6 Timezone Issue

Posted: Sat Feb 06, 2021 1:57 pm
by sw!tch
I think the confusion is you actually downloaded 3.0.3.7 release. (it was just released) There was a bug in the intial release where they failed to update the version, it was being reported as 3.0.3.6 in the admin panel.

The timezone setting wasn't available by default in opencart prior to 3.0.3.7, unless you installed a marketplace extension.

Re: OC 3.0.3.6 Timezone Issue

Posted: Sat Feb 06, 2021 1:58 pm
by by mona
:clap:

This is going to be fun :laugh:

AND @vthompson thank you again - would you mind changing the title to 3.0.3.7 and adding [SOLVED] as that will be of use to many people I suspect .. :ok:

Re: OC 3.0.3.6 Timezone Issue

Posted: Sat Feb 06, 2021 2:07 pm
by vthompson
Well, if it's 3.0.3.7, fine. The issue still stands. I attached the screenshot of setting the timezone.

Re: OC 3.0.3.7 Timezone Issue

Posted: Sat Feb 06, 2021 4:49 pm
by sw!tch
vthompson wrote:
Sat Feb 06, 2021 2:07 pm
Well, if it's 3.0.3.7, fine. The issue still stands. I attached the screenshot of setting the timezone.
Looks like this is a valid bug, haven't spent enough time on 3.0.3.7 to look into it, but was able to quickly duplicate. Since it potentially deals with sessions, the fix should really be addressed from the core.

You could open an issue request on Opencarts Github.

Re: [SOLUTION] OC 3.0.3.7 Timezone Issue

Posted: Sun Feb 07, 2021 1:26 pm
by straightlight
Untested but in admin/controller/setting/setting.php file,

Edit: Modification has been known to not working; error with string as an array given. Codes removed.

Re: [SOLUTION] OC 3.0.3.7 Timezone Issue

Posted: Wed Feb 10, 2021 6:14 am
by sukhbirgs
There could be another issue for 3.0.3.7, i was getting api error editing admin order's and tracked it down to System->framework.php

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

For me it was executing "SET time_zone = '+00:00'" where as i am in +7
Commenting out this line and i am able to edit order's.
Good luck

Re: [SOLUTION] OC 3.0.3.7 Timezone Issue

Posted: Wed Feb 10, 2021 10:10 am
by straightlight
sukhbirgs wrote:
Wed Feb 10, 2021 6:14 am
There could be another issue for 3.0.3.7, i was getting api error editing admin order's and tracked it down to System->framework.php

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

For me it was executing "SET time_zone = '+00:00'" where as i am in +7
Commenting out this line and i am able to edit order's.
Good luck
Which PHP version are you using?

Re: [SOLUTION] OC 3.0.3.7 Timezone Issue

Posted: Wed Feb 10, 2021 7:06 pm
by sw!tch
I think the problem lies in framework.php with the date_default_timezone_set($config->get('date_timezone'));

For example: If you look at the following line https://github.com/opencart/opencart/bl ... rk.php#L15

In framework.php it's set default to UTC, it is probably taking priority over date() in the session DB class before the startup.php timezone override can be called.

If that's the case, then the timezone becomes out of sync and would cause the login issue. This could also explain why it works with file sessions as the OP mentioned ( no query is done with file sessions).

If you encounter this, open an issue ticket on the OC GitHub so it can be looked into as its better addressed from the core.

If you get locked out or cannot login try setting the Timezone back to UTC

In phpmyadmin go to your oc_setting table and under the key column look for config_timezone, set the value back to UTC, clear your browser history and try to login again.
-

Re: [SOLUTION] OC 3.0.3.7 Timezone Issue

Posted: Sun Feb 28, 2021 12:04 am
by alejandroalcala
The solution below provided by straightlight, was sucefully applied in my OpenCart installation 3.0.3.7

Waiting for an official update.

Thank You.

Re: [SOLUTION] OC 3.0.3.7 Timezone Issue

Posted: Sun Feb 28, 2021 12:25 am
by straightlight
alejandroalcala wrote:
Sun Feb 28, 2021 12:04 am
The solution below provided by Stream, was sucefully applied in my OpenCart installation 3.0.3.7

Waiting for an official update.

Thank You.
What solution?

Re: [SOLUTION] OC 3.0.3.7 Timezone Issue

Posted: Sun Feb 28, 2021 1:04 am
by xxvirusxx
vthompson wrote:
Fri Feb 05, 2021 11:34 am
session engine from db to file in the system/config/default.php
Like in Master Branch

https://github.com/opencart/opencart/bl ... lt.php#L39

Re: [SOLUTION] OC 3.0.3.7 Timezone Issue

Posted: Sun Feb 28, 2021 1:26 am
by alejandroalcala
straightlight wrote:
Sun Feb 28, 2021 12:25 am
alejandroalcala wrote:
Sun Feb 28, 2021 12:04 am
The solution below provided by Stream, was sucefully applied in my OpenCart installation 3.0.3.7

Waiting for an official update.

Thank You.
What solution?
Solution that you provide. Fixed your name, sorry hehehehehe (i am learning about how to post correctly in forums).
Now my installation of open cart works fine...

Re: [SOLUTION] OC 3.0.3.7 Timezone Issue

Posted: Sun Feb 28, 2021 3:33 am
by straightlight
alejandroalcala wrote:
Sun Feb 28, 2021 1:26 am
straightlight wrote:
Sun Feb 28, 2021 12:25 am
alejandroalcala wrote:
Sun Feb 28, 2021 12:04 am
The solution below provided by Stream, was sucefully applied in my OpenCart installation 3.0.3.7

Waiting for an official update.

Thank You.
What solution?
Solution that you provide. Fixed your name, sorry hehehehehe (i am learning about how to post correctly in forums).
Now my installation of open cart works fine...
Excellent, thanks for your feedback.

Re: [SOLUTION] OC 3.0.3.7 Timezone Issue

Posted: Sun Feb 28, 2021 11:59 pm
by straightlight
ClaudePlouffe wrote:
Sun Feb 28, 2021 11:51 pm
It think the problem is in the system/framework.php which is setting timezone to 'date_timezone' even after a 'config_time zone' is set in admin/controller/setting/setting.php

Here's my fix

in system/framework.php replace
date_default_timezone_set($config->get('date_timezone'));

with
if ($config->has('config_timezone')) {
date_default_timezone_set($config->get('config_timezone'));
} else {
date_default_timezone_set($config->get('date_timezone'));
}
Either solution could work in this scenario.