v157 DATE_FORMAT_DATE_PICKER error, if date format change and update product.
v157 DATE_FORMAT_DATE_PICKER error, if date format change and update product.
Can I change the 32-line code in admin / includes / languages / english.php or in my native language?
define ('DATE_FORMAT_DATE_PICKER', 'yy-mm-dd'); // Use only 'dd', 'mm' and 'yy' here in any order
I tried modifying the DATE_FORMAT_DATE_PICKER format to the 'dd-mm-yy' format, but when I updated the product,
Admin dashboard cannot appear.
(This page isn't workinglocalhost is currently unable to handle this request.
HTTP ERROR 500
And the LOG file says:
[30-Jun-2020 01:46:28 Europe / Berlin] Request URI: /toko_zc157/blUrt-CXC-cRisp/index.php?cmd=product&cPath=4&pID=2&action=update_product, IP address: :: 1
-> PHP Fatal error: Uncaught Error: Call to a member function format () on bool in D: \ xampp \ htdocs \ toko_zc157 \ blUrt-CXC-cRisp \ includes \ modules \ update_product.php: 22
Stack trace:
# 0 D: \ xampp \ htdocs \ toko_zc157 \ blUrt-CXC-cRisp \ product.php (33): require ()
# 1 D: \ xampp \ htdocs \ toko_zc157 \ blUrt-CXC-cRisp \ index.php (11): require ('D: \\ xampp \\ htdocs ...')
# 2 {play}
thrown in D: \ xampp \ htdocs \ toko_zc157 \ blUrt-CXC-cRisp \ includes \ modules \ update_product.php on line 22.
thank
Re: v157 DATE_FORMAT_DATE_PICKER error, if date format change and update product.
Were you in the middle of editing the product when the language date define was changed? I modified just that text as described, logged into admin, navigated to a product, edited the available date to tomorrow, did an update and then a confirm... stored fine for the date entered...
Re: v157 DATE_FORMAT_DATE_PICKER error, if date format change and update product.
Quote:
Originally Posted by
mc12345678
Were you in the middle of editing the product when the language date define was changed? I modified just that text as described, logged into admin, navigated to a product, edited the available date to tomorrow, did an update and then a confirm... stored fine for the date entered...
Steps I get an error :;
1. Fresh install of v157 with product samples.
2. admin/includes/languages/english.php, line no. 32 change format date, from 'yy-mm-dd' to 'dd-mm-yy'.
3. Catalog -> Categories/Products -> Hardware -> Graphics Cards
4. Click the "Edit Product" button in any product
5. Click the "Preview" button (without editing any thing / leave the Date Available field is empty)
6. Click the "Update" button
ERROR appears:
This page isn't working
localhost is currently unable to handle this request.
HTTP ERROR 500
Re: v157 DATE_FORMAT_DATE_PICKER error, if date format change and update product.
Quote:
Originally Posted by
ihangat2000
Steps I get an error :;
1. Fresh install of v157 with product samples.
2. admin/includes/languages/english.php, line no. 32 change format date, from 'yy-mm-dd' to 'dd-mm-yy'.
3. Catalog -> Categories/Products -> Hardware -> Graphics Cards
4. Click the "Edit Product" button in any product
5. Click the "Preview" button (without editing any thing / leave the Date Available field is empty)
6. Click the "Update" button
ERROR appears:
This page isn't working
localhost is currently unable to handle this request.
HTTP ERROR 500
the problem is if the date is empty. i can confirm this bug.
$dt comes up as FALSE if the $products_date_available is blank. resulting in the:
[29-Jun-2020 22:21:51 America/Los_Angeles] PHP Fatal error: Uncaught Error: Call to a member function format() on bool in /var/www/base157/admin/includes/modules/update_product.php:22
i would suggest line 19 in
admin/includes/modules/update_product.php
changed to:
PHP Code:
if (DATE_FORMAT_DATE_PICKER != 'yy-mm-dd' && !empty($products_date_available))
best.
Re: v157 DATE_FORMAT_DATE_PICKER error, if date format change and update product.
Quote:
Originally Posted by
carlwhat
the problem is if the date is empty. i can confirm this bug.
$dt comes up as FALSE if the $products_date_available is blank. resulting in the:
[29-Jun-2020 22:21:51 America/Los_Angeles] PHP Fatal error: Uncaught Error: Call to a member function format() on bool in /var/www/base157/admin/includes/modules/update_product.php:22
i would suggest line 19 in
admin/includes/modules/update_product.php
changed to:
PHP Code:
if (DATE_FORMAT_DATE_PICKER != 'yy-mm-dd' && !empty($products_date_available))
best.
Thank you for your explanation
Re: v157 DATE_FORMAT_DATE_PICKER error, if date format change and update product.
I would recommend localizing the "check" more to the specific line where this "boolean" (false) result was provided... though both tests provide some support.
It is possible to provide information that doesn't fit the necessary/requested format and the sequence is not the default of 'yy-mm-dd'. This causes $dt to be set to false and therefore $dt->format... will cause the error previously seen.
So, either a test of the existence of the method 'format' for the object, a test of emptiness of the $dt variable, or maybe a test of strict falseness against $dt... I would recommend the first one to further the code becoming more OOP. The second one is more along the lines of where things have been going, though a mixture of the two may be necessary.
But, to prevent php operation from ending, I changed:
Code:
$dt = DateTime::createFromFormat($local_fmt, $products_date_available);
$products_date_available = $dt->format('Y-m-d');
To:
Code:
$dt = DateTime::createFromFormat($local_fmt, $products_date_available);
$products_date_available = 'null';
if (!empty($dt)) {
$products_date_available = $dt->format('Y-m-d');
}
This way, the entered $products_date_available would be attempted to be converted, but if it fails causing $dt === false, then the captured value is a nothing value, though perhaps it should instead be whatever it was before through some sort of notification and return to edit...
Re: v157 DATE_FORMAT_DATE_PICKER error, if date format change and update product.
Hi,
thank you again mc1234567! I can confirm this datetime "bug" is still haunting us with the 1.5.8 version too. Also found something else regarding /admin/includes/modules/update_product.php file but perhaps I will start a new thread because my solution to fix it was not very eloquent and the real problem lies elsewhere.
Re: v157 DATE_FORMAT_DATE_PICKER error, if date format change and update product.
Quote:
Originally Posted by
OopsIbrickedIT
Hi,
thank you again mc1234567! I can confirm this datetime "bug" is still haunting us with the 1.5.8 version too. Also found something else regarding /admin/includes/modules/update_product.php file but perhaps I will start a new thread because my solution to fix it was not very eloquent and the real problem lies elsewhere.
Actually it is not a probelm anymore, there was an missing file with helper classes which did not get ulpoaded. It contains all the necessesary functions to sort out date time conversions in 1.5.8. My bad.
Re: v157 DATE_FORMAT_DATE_PICKER error, if date format change and update product.
Here's where you might want to share in case someone else experiences the problem.