Post by sw!tch » Mon Mar 01, 2021 3:43 am

straightlight wrote:
Sun Feb 28, 2021 11:59 pm
ClaudePlouffe wrote:
Sun Feb 28, 2021 11:51 pm
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.
I don't think that would work because $config from the DB hasn't been instantiated yet. For that to work, you would have to move that code further down in framework.php .

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 4:26 am

sw!tch wrote:
Mon Mar 01, 2021 3:43 am
straightlight wrote:
Sun Feb 28, 2021 11:59 pm
ClaudePlouffe wrote:
Sun Feb 28, 2021 11:51 pm
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.
I don't think that would work because $config from the DB hasn't been instantiated yet. For that to work, you would have to move that code further down in framework.php .
Yes, correct. Daniel has imported my code in the master branch (commented code, for now) . Let's see what comes next if applied.

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 ADD Creative » Tue Mar 02, 2021 5:25 am

straightlight wrote:
Mon Mar 01, 2021 4:26 am
Yes, correct. Daniel has imported my code in the master branch (commented code, for now) . Let's see what comes next if applied.
Do you mean this? https://github.com/opencart/opencart/co ... 5aac13d699

That code will not work. array_replace returns an array while date_default_timezone_set expects a string. You will just get "Warning: date_default_timezone_set() expects parameter 1 to be string, array given". Worse in PHP 8 you will get "Fatal error: Uncaught TypeError: date_default_timezone_set(): Argument #1 ($timezoneId) must be of type string, array given".

The issue isn't in admin/controller/setting/setting.php anyway. As others have pointed out, it's to do with how the timezone is set at startup.

www.add-creative.co.uk


Expert Member

Posts

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

Post by straightlight » Tue Mar 02, 2021 6:08 am

ADD Creative wrote:
Tue Mar 02, 2021 5:25 am
straightlight wrote:
Mon Mar 01, 2021 4:26 am
Yes, correct. Daniel has imported my code in the master branch (commented code, for now) . Let's see what comes next if applied.
Do you mean this? https://github.com/opencart/opencart/co ... 5aac13d699

That code will not work. array_replace returns an array while date_default_timezone_set expects a string. You will just get "Warning: date_default_timezone_set() expects parameter 1 to be string, array given". Worse in PHP 8 you will get "Fatal error: Uncaught TypeError: date_default_timezone_set(): Argument #1 ($timezoneId) must be of type string, array given".

The issue isn't in admin/controller/setting/setting.php anyway. As others have pointed out, it's to do with how the timezone is set at startup.
We seem to have another version on the topic where this solution does work, however. As for PHP8, if it does get worst, it's something that's going to have to be worked out.

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 undrwater » Thu Mar 11, 2021 7:55 am

sw!tch wrote:
Wed Feb 10, 2021 7:06 pm

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.
-
Do you happen to know the mysql syntaxt for the same? I don't have phpmyadmin at the moment.

Newbie

Posts

Joined
Thu Mar 11, 2021 7:45 am

Post by sw!tch » Fri Mar 12, 2021 4:29 am

undrwater wrote:
Thu Mar 11, 2021 7:55 am
Do you happen to know the mysql syntaxt for the same? I don't have phpmyadmin at the moment.
As always backup, but below should work.

Code: Select all

UPDATE `oc_setting` SET `value` = 'UTC' WHERE `key` = 'config_timezone';
Another option is to set the system/config/default.php timezone to match what you selected in store settings config_timezone. https://github.com/opencart/opencart/bl ... lt.php#L14

-

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 catontech » Sat Mar 13, 2021 10:45 am

Changing the default date in the config file worked for me. Thanks for the guidance. 8)

Newbie

Posts

Joined
Sat Mar 13, 2021 10:43 am

Post by undrwater » Tue Mar 16, 2021 2:44 am

sw!tch wrote:
Fri Mar 12, 2021 4:29 am

Code: Select all

UPDATE `oc_setting` SET `value` = 'UTC' WHERE `key` = 'config_timezone';
Another option is to set the system/config/default.php timezone to match what you selected in store settings config_timezone. https://github.com/opencart/opencart/bl ... lt.php#L14

-
Thanks for the mysql syntax! Appreciated. I'm getting the following at the top now when trying to edit my site's settings:

Code: Select all

Warning: date_default_timezone_set() expects parameter 1 to be string, array given in /var/www/html/opencart/admin/controller/setting/setting.php on line 350
I can log in fine, but I can't seem to set my store to Maintenance Mode. No other errors.

Newbie

Posts

Joined
Thu Mar 11, 2021 7:45 am

Post by sw!tch » Tue Mar 16, 2021 3:09 am

undrwater wrote:
Tue Mar 16, 2021 2:44 am
Thanks for the mysql syntax! Appreciated. I'm getting the following at the top now when trying to edit my site's settings:

Code: Select all

Warning: date_default_timezone_set() expects parameter 1 to be string, array given in /var/www/html/opencart/admin/controller/setting/setting.php on line 350
I can log in fine, but I can't seem to set my store to Maintenance Mode. No other errors.
Undo the change you made here - viewtopic.php?f=201&t=222369#p813324
-

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 undrwater » Tue Mar 16, 2021 7:57 am

sw!tch wrote:
Tue Mar 16, 2021 3:09 am

Undo the change you made here - viewtopic.php?f=201&t=222369#p813324
-
Beautiful, thank you!

Newbie

Posts

Joined
Thu Mar 11, 2021 7:45 am

Post by Marcomz » Fri Mar 19, 2021 2:53 am

Still has no solution?
I tried several proposals from here, none of which worked.
Whenever I changed the time zone to
America / São_Paulo (-03: 00)
The system disconnected me and I was unable to log in again.
Temporary Solution: So, I blocked the form to not allow changing the time zone.
Until the solution of this problem is solved.
Staying in "UTC (+00:00)" the system works normally.
---
admin\view\template\setting
setting.twig
Change in line alt the select 223:
<select name="config_timezone" id="input-timezone" class="form-control">
<option value="UTC" selected="selected">UTC (+00:00)</option>
</select>
---
This prevents a customer or someone from changing the timezone and causing an error again.
Last edited by Marcomz on Fri Mar 19, 2021 3:09 am, edited 1 time in total.

Newbie

Posts

Joined
Wed Jun 08, 2016 5:01 am

Post by ADD Creative » Fri Mar 19, 2021 3:04 am

Have you tried setting the date_timezone in the config to the same value as the one in your settings?
https://github.com/opencart/opencart/bl ... lt.php#L14

www.add-creative.co.uk


Expert Member

Posts

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

Post by sw!tch » Fri Mar 19, 2021 3:09 am

@Marcomz - You shouldn't have to force the timezone to selected in twig. You might be experiencing some other issue with auto-complete or something.

If you get locked out you can simply set the timezeon back to UTC by running the following query.

Code: Select all

UPDATE `oc_setting` SET `value` = 'UTC' WHERE `key` = 'config_timezone';
Or if you want to use a custom timezone, set the system/config/default.php timezone to match what you selected in store settings config_timezone. https://github.com/opencart/opencart/bl ... lt.php#L14

It's important you clear your browser cache after making these changes.
-

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 Marcomz » Fri Mar 19, 2021 10:50 pm

ADD Creative wrote:
Fri Mar 19, 2021 3:04 am
Have you tried setting the date_timezone in the config to the same value as the one in your settings?
https://github.com/opencart/opencart/bl ... lt.php#L14
OK, now it’s working the way you suggested, Thanks!

BRT is the Brazilian official time code, Brasília time.
In the drop down list we don't have the option: Brasília, so I put São Paulo and it worked.
There should be Brasília on the Drop Down list, In Brazil we now have 4 official time zones:
ACT Time of Acre UTC − 5 (BRT – 2)
AMT Time of Amazonas UTC − 4 (BRT − 1)
BRT Time of Brasília UTC − 3 (BRT)
FNT Time of Fernando de Noronha UTC − 2 (BRT + 1)
https://pt.wikipedia.org/wiki/Fusos_hor ... _no_Brasil

Thanks sw!tch too.

Newbie

Posts

Joined
Wed Jun 08, 2016 5:01 am

Post by ADD Creative » Sat Mar 20, 2021 12:07 am

Marcomz wrote:
Fri Mar 19, 2021 10:50 pm
OK, now it’s working the way you suggested, Thanks!

BRT is the Brazilian official time code, Brasília time.
In the drop down list we don't have the option: Brasília, so I put São Paulo and it worked.
There should be Brasília on the Drop Down list, In Brazil we now have 4 official time zones:
ACT Time of Acre UTC − 5 (BRT – 2)
AMT Time of Amazonas UTC − 4 (BRT − 1)
BRT Time of Brasília UTC − 3 (BRT)
FNT Time of Fernando de Noronha UTC − 2 (BRT + 1)
https://pt.wikipedia.org/wiki/Fusos_hor ... _no_Brasil

Thanks sw!tch too.
The list is generated by PHP and is based on the IANA timezone database. See https://en.wikipedia.org/wiki/Time_in_B ... e_database and https://en.wikipedia.org/wiki/Tz_database.

www.add-creative.co.uk


Expert Member

Posts

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

Post by Marcomz » Sat Mar 20, 2021 3:54 am

ADD Creative wrote:
Sat Mar 20, 2021 12:07 am
Marcomz wrote:
Fri Mar 19, 2021 10:50 pm
OK, now it’s working the way you suggested, Thanks!

BRT is the Brazilian official time code, Brasília time.
In the drop down list we don't have the option: Brasília, so I put São Paulo and it worked.
There should be Brasília on the Drop Down list, In Brazil we now have 4 official time zones:
ACT Time of Acre UTC − 5 (BRT – 2)
AMT Time of Amazonas UTC − 4 (BRT − 1)
BRT Time of Brasília UTC − 3 (BRT)
FNT Time of Fernando de Noronha UTC − 2 (BRT + 1)
https://pt.wikipedia.org/wiki/Fusos_hor ... _no_Brasil

Thanks sw!tch too.
The list is generated by PHP and is based on the IANA timezone database. See https://en.wikipedia.org/wiki/Time_in_B ... e_database and https://en.wikipedia.org/wiki/Tz_database.
Yes, I saw that. It must be right.
I don't know how this works, in the INA database there is no Brasilia, but São Paulo has the same time as Brasilia

Newbie

Posts

Joined
Wed Jun 08, 2016 5:01 am

Post by trbolexis » Sat Mar 20, 2021 4:17 pm

ADD Creative wrote:
Fri Mar 19, 2021 3:04 am
Have you tried setting the date_timezone in the config to the same value as the one in your settings?
https://github.com/opencart/opencart/bl ... lt.php#L14
This was the solution for me to be able to properly set the timezone.

Changed the time zone in default.php to "America/Los_Angeles", and then set the TZ in the admin panel. No issues so far; less a strange issue with orders reverting back to processing inexplicably.

Newbie

Posts

Joined
Thu Oct 22, 2020 8:23 am

Post by xxvirusxx » Sat Mar 20, 2021 4:56 pm

You can change from db to file like is in Master Branch.

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by flywatches » Tue Mar 30, 2021 11:37 am

Is there a date set for when this will be fixed/updated? I am testing moving over a 20 year old ecommerce business from Prestashop to Open Cart and my first welcome is this basic bug/error shutting down access to the admin. I tried all of the above mentioned suggestions and they do not work for me. In addition, I changed my password and now I cannot login or even get a password reset.

Jonathan


New member

Posts

Joined
Fri Oct 19, 2012 11:38 pm
Location - Gilbert, AZ

Post by ADD Creative » Tue Mar 30, 2021 7:43 pm

flywatches wrote:
Tue Mar 30, 2021 11:37 am
Is there a date set for when this will be fixed/updated? I am testing moving over a 20 year old ecommerce business from Prestashop to Open Cart and my first welcome is this basic bug/error shutting down access to the admin. I tried all of the above mentioned suggestions and they do not work for me. In addition, I changed my password and now I cannot login or even get a password reset.
If you have tried setting the config_timezone back to 'UTC' in the database, setting 'date_timezone' in system/config/default.php to the same as the database setting or seting 'session_engine' to 'file' in system/config/default.php and none of the worked after clearing your browser cache and cookies. Then that suggests a different issue.

You can reset the the admin password directly in the database. Do a search on how to do this.

www.add-creative.co.uk


Expert Member

Posts

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

Users browsing this forum: No registered users and 35 guests