Bool error using CSV Import version 1.17 or 1.18
3 posts by 3 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: 14 hours ago (RSS)
By nmsinc - November 2 - edited: November 2
I have an issue with the CSV import plugin version 1.17 or 1.18 when attempting to import a CVS file!
I removed the array function preset in the array_functions.php file when I moved to PHP version 8.5 to correct for PHP now using a preset array and I'm now receiving the following error when importing:
Warning: Cannot use bool as arrayWarning: Cannot use bool as arrayWarning: Cannot use bool as arrayWarning: Cannot use bool as arrayWarning: Cannot use bool as arrayWarning: Cannot use bool as arrayWarning: Cannot use bool as arrayWarning: Cannot use bool as arrayWarning: Cannot use bool as arrayWarning: Cannot use bool as arrayWarning: Cannot use bool as arrayWarning: Cannot use bool as arrayWarning: Cannot use bool as arrayWarning: Cannot use bool as arrayWarning: Cannot use bool as arrayWarning: Cannot use bool as arrayWarning: Cannot use bool as arrayWarning: Cannot use bool as array
By Lucia - November 5
Hi nmsinc,
This is a bug that we're aware of, and it should be fixed in an upcoming update to the plugin. However, in the meantime, here's how you can get it working.
Starting from a fresh copy of CSV Import 1.18 (https://interactivetools.com/plugins/csv-import/)
In csvImport_functions.php, on line 252, change this:
[$colValues, $offset] = _csvParser_getNextLine($csvFilepath);
to this:
$nextLine = _csvParser_getNextLine($csvFilepath);
if (!$nextLine) { break; }
[$colValues, $offset] = $nextLine;
And then on line 503, change this:
[$colValues, $offset] = _csvParser_getNextLine($csvFilepath, $setOffset);
to this:
$nextLine = _csvParser_getNextLine($csvFilepath, $setOffset);
if (!$nextLine) { $done = true; break; } // end of file
[$colValues, $offset] = $nextLine;
Let me know if you have any further issues!
Thanks,
Technical Lead
interactivetools.com
Thanks for sharing this fix, Lucia. Checking for false before using the return value makes sense, since that is where the bool warning comes from when a lookup fails. This is a useful workaround for anyone seeing the same warning after moving to PHP 8.5, and good to know it will be fixed in the next release too.