All add-ons currently require PHP 7.4 or greater.

On July 4th 2024 PHP 8.2 will be the new minimum requirement for all add-ons. Expect any add-on released after that date to require 8.2 or greater. Some releases may not immediately take advantage of 8.x specific features in PHP, which means you might, be able to continue using new releases in PHP 7.4, however, if you experience an error the first thing you should do is update to PHP 8.2 then create a support ticket if the error persists.

Publisher does not support the Fluid field type. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: csv import synchronization freezes

Status Resolved
Add-on / Version DataGrab 5.0.5
Severity
EE Version EE6.4.14

bart van zandvoort

Sep 19, 2023

Morning. So last week I noticed datagrab wouldn’t synchronise any csv’s. The ajax script for syncing kept running and eventually the site crashed.
Latest version of EE6, and Datagrab 5.0.5. and php8. So I’ve been digging into the errors and it came down to /datagrab/datatypes/csv/dt.databgrab_csv.php line 141 in function getCsv. Looks like fgetcsv is not able to use $this->settings[“encloser”] when it’s a single or double quote. I’ve hardcoded line 141 to:
return fgetcsv($handle, 0, $this->settings[“delimiter”], ‘“’);
and now datagrab runs a csv sync … can you guys see if you can make a fix for a future version for this? it’s working now, but it would be great to have a inbuilt solution.

 

 

#1

BoldMinded (Brian)

Did you var_dump the value of $this->settings[‘enclosed’]? If you had to hard code it to a ” then it sounds to me like the setting value isn’t present at all. What does your import config screen look like? Did you try to re-save the import?

#2

bart van zandvoort

Hi Brian,

I’ve added screenshots on what’s going on in the main ticket. Doens’t matter if I resave the import or not, behaviour stays the same.

the errors is what I see when I directly enter the action-url, this led me to the hardcoded fix.

#3

bart van zandvoort

We’re using PHP8 also. Might be usefull to know.

#4

BoldMinded (Brian)

Have you tried var_dump($this->settings); on line 140 or so?

#5

bart van zandvoort

array(4) { [“filename”]=> string(25) “{base_url}/csv/agenda.csv” [“delimiter”]=> string(1) “;” [“encloser”]=> string(0) “” [“skip”]=> string(1) “1” } array(4) { [“filename”]=> string(25) “{base_url}/csv/agenda.csv” [“delimiter”]=> string(1) “;” [“encloser”]=> string(0) “” [“skip”]=> string(1) “1” } array(4) { [“filename”]=> string(25) “{base_url}/csv/agenda.csv” [“delimiter”]=> string(1) “;” [“encloser”]=> string(0) “” [“skip”]=> string(1) “1” } array(4) { [“filename”]=> string(25) “{base_url}/csv/agenda.csv” [“delimiter”]=> string(1) “;” [“encloser”]=> string(1) “”” [“skip”]=> string(1) “1” } array(4) { [“filename”]=> string(25) “{base_url}/csv/agenda.csv” [“delimiter”]=> string(1) “;” [“encloser”]=> string(1) “”” [“skip”]=> string(1) “1” } array(4) { [“filename”]=> string(25) “{base_url}/csv/agenda.csv” [“delimiter”]=> string(1) “;” [“encloser”]=> string(1) “”” [“skip”]=> string(1) “1” }

#6

BoldMinded (Brian)

Change line 141 to this:

return fgetcsv($handle, 0, $this->settings['delimiter'] ?? ',', $this->settings['encloser'] ?? '"');
#7

bart van zandvoort

does that work? because $this-settings[‘encloser’] is set, but it’s empty … ?? will only work when a variable is not set, If i’m not mistaken.

#8

BoldMinded (Brian)

Correct, I added the ?? operator just in-case someone didn’t save a value. I’m not sure how it’s not working for you b/c it is clearly set to a double quote in the settings array. What exact version of PHP 8? 8.0, 8.1 or 8.2?

#9

bart van zandvoort

PHP 8.2

#10

BoldMinded (Brian)

Can you share a small sample of your CSV file? Just 3-5 rows/entries I can test the import with locally?

#11

bart van zandvoort

Comment has been marked private.

#12

BoldMinded (Brian)

Have you tried wrapping quotes around you column values? The enclosure is is defined as a quote but nothing is wrapped in quotes. I think this is a .csv formatting issue more than a bug in DataGrab. I tried importing it and it was only able to find the first row of data and after that it failed.

#13

BoldMinded (Brian)

Comment has been marked private.

Login to reply