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 .straightlight wrote: ↑Sun Feb 28, 2021 11:59 pmEither solution could work in this scenario.ClaudePlouffe wrote: ↑Sun Feb 28, 2021 11:51 pmHere'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'));
}
Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!
Yes, correct. Daniel has imported my code in the master branch (commented code, for now) . Let's see what comes next if applied.sw!tch wrote: ↑Mon Mar 01, 2021 3:43 amI 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 .straightlight wrote: ↑Sun Feb 28, 2021 11:59 pmEither solution could work in this scenario.ClaudePlouffe wrote: ↑Sun Feb 28, 2021 11:51 pmHere'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'));
}
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Do you mean this? https://github.com/opencart/opencart/co ... 5aac13d699straightlight wrote: ↑Mon Mar 01, 2021 4:26 amYes, correct. Daniel has imported my code in the master branch (commented code, for now) . Let's see what comes next if applied.
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.ADD Creative wrote: ↑Tue Mar 02, 2021 5:25 amDo you mean this? https://github.com/opencart/opencart/co ... 5aac13d699straightlight wrote: ↑Mon Mar 01, 2021 4:26 amYes, correct. Daniel has imported my code in the master branch (commented code, for now) . Let's see what comes next if applied.
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.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
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';
-
Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!
Thanks for the mysql syntax! Appreciated. I'm getting the following at the top now when trying to edit my site's settings:sw!tch wrote: ↑Fri Mar 12, 2021 4:29 amAnother 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#L14Code: Select all
UPDATE `oc_setting` SET `value` = 'UTC' WHERE `key` = 'config_timezone';
-
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
Undo the change you made here - viewtopic.php?f=201&t=222369#p813324undrwater wrote: ↑Tue Mar 16, 2021 2:44 amThanks for the mysql syntax! Appreciated. I'm getting the following at the top now when trying to edit my site's settings:I can log in fine, but I can't seem to set my store to Maintenance Mode. No other errors.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
-
Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!
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.
https://github.com/opencart/opencart/bl ... lt.php#L14
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';
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!
OK, now it’s working the way you suggested, Thanks!ADD Creative wrote: ↑Fri Mar 19, 2021 3:04 amHave 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
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.Marcomz wrote: ↑Fri Mar 19, 2021 10:50 pmOK, 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.
Yes, I saw that. It must be right.ADD Creative wrote: ↑Sat Mar 20, 2021 12:07 amThe 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.Marcomz wrote: ↑Fri Mar 19, 2021 10:50 pmOK, 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.
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
This was the solution for me to be able to properly set the timezone.ADD Creative wrote: ↑Fri Mar 19, 2021 3:04 amHave 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
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.
Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer
Jonathan
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.flywatches wrote: ↑Tue Mar 30, 2021 11:37 amIs 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.
You can reset the the admin password directly in the database. Do a search on how to do this.
Users browsing this forum: No registered users and 5 guests