Forums / General Questions / 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.

Views: 2,954

Results 1 to 9 of 9
30 Jun 2020, 12:20 AM
#1
ihangat2000 avatar

ihangat2000

New Zenner

Join Date:
Mar 2012
Location:
yogyakarta, indonesia
Posts:
16
Plugin Contributions:
2

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

30 Jun 2020, 3:12 AM
#2
mc12345678 avatar

mc12345678

Totally Zenned

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

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...

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

30 Jun 2020, 4:13 AM
#3
ihangat2000 avatar

ihangat2000

New Zenner

Join Date:
Mar 2012
Location:
yogyakarta, indonesia
Posts:
16
Plugin Contributions:
2

Re: v157 DATE_FORMAT_DATE_PICKER error, if date format change and update product.

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

30 Jun 2020, 5:40 AM
#4
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,969
Plugin Contributions:
8

Re: v157 DATE_FORMAT_DATE_PICKER error, if date format change and update product.

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:

if (DATE_FORMAT_DATE_PICKER != 'yy-mm-dd' && !empty($products_date_available))

best.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

30 Jun 2020, 8:02 AM
#5
ihangat2000 avatar

ihangat2000

New Zenner

Join Date:
Mar 2012
Location:
yogyakarta, indonesia
Posts:
16
Plugin Contributions:
2

Re: v157 DATE_FORMAT_DATE_PICKER error, if date format change and update product.

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:

if (DATE_FORMAT_DATE_PICKER != 'yy-mm-dd' && !empty($products_date_available))

> 
> best.


Thank you for your explanation
30 Jun 2020, 1:43 PM
#6
mc12345678 avatar

mc12345678

Totally Zenned

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

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:

    $dt = DateTime::createFromFormat($local_fmt, $products_date_available); 
    $products_date_available = $dt->format('Y-m-d'); 

To:

    $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...

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

29 Nov 2022, 2:46 AM
#7
oopsibrickedit avatar

oopsibrickedit

Zen Follower

Join Date:
Mar 2012
Posts:
132
Plugin Contributions:
0

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.

16 Dec 2022, 2:37 PM
#8
oopsibrickedit avatar

oopsibrickedit

Zen Follower

Join Date:
Mar 2012
Posts:
132
Plugin Contributions:
0

Re: v157 DATE_FORMAT_DATE_PICKER error, if date format change and update product.

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.

16 Dec 2022, 11:20 PM
#9
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,848
Plugin Contributions:
17

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.

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com