Error With PHP 7.2 And CSV Import Plugin v1.11

7 posts by 3 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: June 14, 2018   (RSS)

By leo - June 11, 2018

Hi Steve,

Sorry for the late response. I have tested under the same environment with some test csv files and couldn't get the error. It may be the file that's not formated very well.

Leo - PHP Programmer (in training)
interactivetools.com

By gregThomas - June 11, 2018

Hi Steve,

Dave asked me to look into this in more detail. I installed PHP version 7.3 and was able to replicate the problem, it looks like the PHP count function is much stricter in the latest version. If the last line of a CSV is blank (which it is if the CSV is exported from the CSV Export plugin) then that error is thrown.

You can resolve the issue by adding the following to line 499 of csv_functions.php:

    list($colValues, $offset) = _csvParser_getNextLine($csvFilepath, $setOffset);
    if(!$colValues){ $done = true; break; }
    $maxColumnCount = max($maxColumnCount, count($colValues));

NOTE: I've not thoroughly tested this change yet, so I'd recommend doing a few test uploads before you use it on any client sites.

Thanks,

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By Steve99 - June 12, 2018

Hi Greg,

Thanks for looking into this further. I've updated the csv func file accordingly, and have performed a series of test imports with successful results.

Best,
Steve

By gregThomas - June 12, 2018 - edited: June 12, 2018

Hi Steve,

Good to hear that worked. I'll do some tests on the fix and should have a new version of the plugin released in the next couple of days. 

Cheers,

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By gregThomas - June 14, 2018 - edited: June 14, 2018

Hey Steve,

I've released a patched version of the plugin, you can download it here:

https://www.interactivetools.com/add-ons/csv-import/

In the end, the only change I made was to add that single line of code, so you can stick with your patched version if you prefer.

Thanks again for bringing that issue to our attention.

Cheers,

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By Steve99 - June 14, 2018

Hey Greg,

Sure thing, thanks for the update!

Best,
Steve