chaddro / EasyPopulate-4.0

Data import and export module for Zencart 1.3.x and 1.5.x
GNU General Public License v2.0
24 stars 31 forks source link

Import function gives incorrect special price dates on PHP 5.6+ #18

Closed ultralisk- closed 9 years ago

ultralisk- commented 9 years ago

My test server is running windows, PHP 5.6.8. When I export a CSV and import it again, the special price dates all get set to the 1970, making them inactive.

easypopulate_4_import.php, line 1521~ seems to be the cause

// using new date functions - chadd
$v_specials_date_avail = ($v_specials_date_avail == true) ? date("Y-m-d H:i:s",strtotime($v_specials_date_avail)) : "0001-01-01";
$v_specials_expires_date = ($v_specials_expires_date == true) ? date("Y-m-d H:i:s",strtotime($v_specials_expires_date)) : "0001-01-01";

To test, I tried this code on both my test server and my production server

<?php
$v_specials_expires_date = "0001-01-01";
echo date("Y-m-d H:i:s",strtotime($v_specials_expires_date));

Test server running Windows, PHP 5.6.8 outputs 1970-01-01 01:00:00 Production server running Linux PHP 5.4.34 outputs 0001-01-01 00:00:00

mc12345678 commented 9 years ago

Sorry to not have seen this earlier, I thought I got notified of such posts, but I guess I need to figure out how to ensure I do get notified.

Which export format/method is used (state export then import caused an issue)? Are the v_specials_date_avail and v_specials_expires_date columns in the file that is then imported? What is the value of the v_specials_date_avail and v_specials_expires_date upon export where this issue is seen? Is it 0001-01-01 upon export, that when then uploaded is converted to the "first date considered" by PHP of 1970-01-01 01:00:00?

The only reason this code section is run to update the date is because the v_specials_price column is present and the value is not null. Depending on that information, may need to programmatically identify the presence of the field(s) to then effect or not the current status or evaluate the value such that if it is 0001-01-01 then not to change its value, but instead use the direct assignment of 0001-01-01...

mc12345678 commented 9 years ago

Mind trying the following? $v_specials_date_avail = ($v_specials_date_avail == true && $v_specials_date_avail > "0001-01-01") ? date("Y-m-d H:i:s", strtotime($v_specials_date_avail)) : "0001-01-01"; $v_specials_expires_date = ($v_specials_expires_date == true && $v_specials_expires_date > "0001-01-01") ? date("Y-m-d H:i:s", strtotime($v_specials_expires_date)) : "0001-01-01";

ultralisk- commented 9 years ago

Apologies for the late reply. I made the changes you mentioned above and did another export/import. This time the dates works as expected.

Thanks for the update!

mc12345678 commented 9 years ago

No, thank you for identifying and confirming. Will be in the next update.