Zen Cart Logo
Forums / Upgrading to 1.5.x / After upgrading to 1.5.7d - PHP Fatal error: 1067:Invalid default value

After upgrading to 1.5.7d - PHP Fatal error: 1067:Invalid default value

Views: 1,749

Results 1 to 6 of 6
19 Nov 2022, 4:05 AM
#1
peter_pechesud avatar

peter_pechesud

New Zenner

Join Date:
Nov 2022
Location:
St-Lambert, Canada
Posts:
29
Plugin Contributions:
0

After upgrading to 1.5.7d - PHP Fatal error: 1067:Invalid default value

Trying to upgrade from version (1.5.5F + super order) to 1.5.7d, using PHP 7.4.3 MySql 5.5.5
After installation of the version and after ZC_INSTALL, it works well on the catalog pages but I always have this error when I try to connect to the Admin page.

[18-Nov-2022 22:36:17 America/New_York] Request URI: /pechesud/bureau/index.php?cmd=login&camefrom=index.php, IP address: 127.0.0.1
#1 trigger_error() called at [D:\xampp734\htdocs\pechesud\includes\classes\db\mysql\query_factory.php:171]
#2 queryFactory->show_error() called at [D:\xampp734\htdocs\pechesud\includes\classes\db\mysql\query_factory.php:143]
#3 queryFactory->set_error() called at [D:\xampp734\htdocs\pechesud\includes\classes\db\mysql\query_factory.php:270]
#4 queryFactory->Execute() called at [D:\xampp734\htdocs\pechesud\bureau\includes\installers\super_orders\4_0_11.php:10]
#5 include(D:\xampp734\htdocs\pechesud\bureau\includes\installers\super_orders\4_0_11.php) called at [D:\xampp734\htdocs\pechesud\bureau\includes\init_includes\init_so_config.php:57]
#6 require_once(D:\xampp734\htdocs\pechesud\bureau\includes\init_includes\init_so_config.php) called at [D:\xampp734\htdocs\pechesud\includes\autoload_func.php:37]
#7 require(D:\xampp734\htdocs\pechesud\includes\autoload_func.php) called at [D:\xampp734\htdocs\pechesud\bureau\includes\application_top.php:37]
#8 require(D:\xampp734\htdocs\pechesud\bureau\includes\application_top.php) called at [D:\xampp734\htdocs\pechesud\bureau\login.php:8]
#9 require(D:\xampp734\htdocs\pechesud\bureau\login.php) called at [D:\xampp734\htdocs\pechesud\bureau\index.php:11]
--> PHP Fatal error: 1067:Invalid default value for 'last_modified' :: ALTER TABLE zen_so_payments CHANGE date_posted date_posted DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' ==> (as called by) D:\xampp734\htdocs\pechesud\bureau\includes\installers\super_orders\4_0_11.php on line 10 <== in D:\xampp734\htdocs\pechesud\includes\classes\db\mysql\query_factory.php on line 171.

I didn't have error during data convertion with ZC_install, I check all the logs. Do I need to fixx something in mySQL configuration ?

19 Nov 2022, 6:25 AM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: After upgrading to 1.5.7d - PHP Fatal error: 1067:Invalid default value

The problem is that when the plugin is attempting to modify the super orders database table, there are issues identified with data stored in the date_modified field. zc_install and core zen Cart do not attempt to modify that table, therefore the issue would not have been discovered that way.

After making a backup of your database, try the following from admin->tools->install sql patches:

UPDATE so_payments SET date_modified = '0001-01-01 00:00:00' WHERE CAST(date_modified AS CHAR(19)) = '0000-00-00 00:00:00';

If the above is attempted from within utilities such as phpMyAdmin, be sure to include or address the table prefix as well.

19 Nov 2022, 11:04 AM
#3
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,690
Plugin Contributions:
56

Re: After upgrading to 1.5.7d - PHP Fatal error: 1067:Invalid default value

You can read more about this in the documentation.

https://docs.zen-cart.com/user/upgrading/date_standardization/

19 Nov 2022, 12:00 PM
#4
peter_pechesud avatar

peter_pechesud

New Zenner

Join Date:
Nov 2022
Location:
St-Lambert, Canada
Posts:
29
Plugin Contributions:
0

Re: After upgrading to 1.5.7d - PHP Fatal error: 1067:Invalid default value

Thanks you for the clues

19 Nov 2022, 1:09 PM
#5
peter_pechesud avatar

peter_pechesud

New Zenner

Join Date:
Nov 2022
Location:
St-Lambert, Canada
Posts:
29
Plugin Contributions:
0

Re: After upgrading to 1.5.7d - PHP Fatal error: 1067:Invalid default value

I tried to ALTER TABLE zen_so_payments in PHPAdmin, but I still have a issue when it's time to ALTER TABLE. Here what I did:

UPDATE zen_so_payments SET date_posted = '0001-01-01 00:00:00' WHERE CAST(date_posted AS CHAR(19)) = '0000-00-00 00:00:00'; (passed)
UPDATE zen_so_payments SET last_modified = '0001-01-01 00:00:00' WHERE CAST(last_modified AS CHAR(19)) = '0000-00-00 00:00:00';* (passed)*

ALTER TABLE zen_so_payments MODIFY COLUMN date_posted datetime NOT NULL default '0001-01-01 00:00:00'; *(Failled)
*
MySQL said: Documentation

#1067 - Invalid default value for 'last_modified'

PHPAdmin seems to check if all fields (default value) is ok, I also try manually to change the default value in structure browser and I have the same message.

19 Nov 2022, 10:00 PM
#6
peter_pechesud avatar

peter_pechesud

New Zenner

Join Date:
Nov 2022
Location:
St-Lambert, Canada
Posts:
29
Plugin Contributions:
0

Re: After upgrading to 1.5.7d - PHP Fatal error: 1067:Invalid default value

Finally found the issue, if you are using XAMPP 7.4.3, by default SQL_MODE is set STRICT TRANSACTION TABLES mode. To fix the issue, you need to update my.ini and change sql_mode=''.
*
Disabling STRICT_TRANS_TABLES mode

However to allow the format 0000-00-00 00:00:00you have to disable STRICT_TRANS_TABLES mode in mysql config file or by command

By command

SET sql_mode = '';

or

SET GLOBAL sql_mode = '';

Using the keyword GLOBAL requires super previliges and it affects the operations all clients connect from that time on

if above is not working than go to /etc/mysql/my.cnf (as per ubuntu) and comment out STRICT_TRANS_TABLES

Also, if you want to permanently set the sql mode at server startup then include SET sql_mode='' in my.cnf on Linux or MacOS. For windows this has to be done in my.ini file.*