I considered that; however, didn't see how the maximum value of 35 had been determined. I of course also didn't look into each of the "time"ish types to see what the various maximums are/were and focused on datetime as it is the combination of both date and time and applied here. :)
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
Hi Guys,
Finally what is the recommended or final solution for the specific problem
Every time someone logs on the store the following error appears. ZC 1.5.7.c, Mysql 5.7.31, PHP 7.4.23
[27-Sep-2021 03:26:14 UTC] Request URI: /index.php?main_page=login, IP address: 114.119.129.92
#1 zen_set_field_length() called at [/includes/templates/bootstrap/templates/tpl_modules_create_account.php:174]
#2 require(/includes/templates/bootstrap/templates/tpl_modules_create_account.php) called at [/includes/templates/bootstrap/templates/tpl_login_default.php:138]
#3 require(/includes/templates/bootstrap/templates/tpl_login_default.php) called at [/includes/templates/bootstrap/common/tpl_main_page.php:197]
#4 require(/includes/templates/bootstrap/common/tpl_main_page.php) called at [/index.php:94]
--> PHP Warning: A non-numeric value encountered in /includes/functions/functions_general.php on line 746.
stop asking customers for their date of birth.
that’s a simple config switch in the admin to turn off.
best.
By turning off the date of birth all errors including the non-numeric value and the crashing of the database went away!!! I hope this is fixed soon as the DOB is a marketing tool.
Thanks a lot,
George
if you want DOB, refer to post #9 above and do as instructed.
https://www.zen-cart.com/showthread....61#post1378361
That was the first thing I did, more than one time and did not worked. I did the change first in the default/Templates/ as are the instructions and last I did the change in the Boostrap/Templates/ and it not work either. I think @drByte and @lat9 should look into this issue again as turning the DOB off is not a solution.
Addressing the issue at its root-cause requires change to /includes/classes/db/mysql/query_factory.php. This is the class that creates the $db object, so be sure to make a backup and place the site into maintenance-mode prior to any change.
At the end of the file, find:
and replace that section with:Code:class queryFactoryMeta { function __construct($zp_field) { $type = $zp_field['Type']; $rgx = preg_match('/^[a-z]*/', $type, $matches); $this->type = $matches[0]; $this->max_length = preg_replace('/[a-z\(\)]/', '', $type); } }
That change recognizes that date and datetime type database fields don't include a maximum length in-and-of themselves.Code:class queryFactoryMeta { public function __construct($zp_field) { $type = $zp_field['Type']; switch ($type) { case 'date': $this->max_length = 10; //- YYYY-MM-DD break; case 'datetime': $this->max_length = 19; //- YYYY-MM-DD HH:MM:SS break; default: $rgx = preg_match('/^[a-z]*/', $type, $matches); $this->type = $matches[0]; $this->max_length = preg_replace('/[a-z\(\)]/', '', $type); break; } } }
Last edited by swguy; 4 Nov 2021 at 06:16 PM. Reason: correcting file path
FWIW, I've opened a GitHub issue to track the changes: https://github.com/zencart/zencart/issues/4467
Looking to make that GitHub update, I see that @DrByte has already addressed that change:
Code:class queryFactoryMeta { function __construct($zp_field) { $type = $zp_field['Type']; $rgx = preg_match('/^[a-z]*/', $type, $matches); $this->type = $matches[0]; $this->max_length = preg_replace('/[a-z\(\)]/', '', $type); if (empty($this->max_length)) { if (strtoupper($type) === 'DATE') $this->max_length = 10; if (strtoupper($type) === 'DATETIME') $this->max_length = 19; // ignores fractional which would be 26 if (strtoupper($type) === 'TIMESTAMP') $this->max_length = 19; // ignores fractional which would be 26 } } }
Bookmarks