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: Errors when importing XML with DataGrab

Status Resolved
Add-on / Version Bloqs 3.2.0
Severity
EE Version 3.5.11

Kees Internetbureau

Sep 20, 2017

When I run an import with DataGrab I get several errors:
Invalid argument supplied for foreach()

user/addons/bloqs/libraries/EEBlocks/Controller/PublishController.php, line 569 show details

Warning

Invalid argument supplied for foreach()

user/addons/bloqs/libraries/EEBlocks/Controller/PublishController.php, line 569 show details

Warning

Invalid argument supplied for foreach()

user/addons/bloqs/libraries/EEBlocks/Controller/PublishController.php, line 569 show details

Warning

Invalid argument supplied for foreach()

user/addons/bloqs/libraries/EEBlocks/Controller/PublishController.php, line 569 show details

Warning

Invalid argument supplied for foreach()

user/addons/bloqs/libraries/EEBlocks/Controller/PublishController.php, line 569 show details

Warning

Cannot modify header information - headers already sent by (output started at ee/legacy/core/Exceptions.php:119)

ee/EllisLab/ExpressionEngine/Boot/boot.common.php, line 535 show details

What could be the problem here?

#1

BoldMinded (Brian)

My guess is there is no block data to be imported and it doesn’t know what to do. I don’t have anything setup to replicate this, but this change may fix it. In that file add this to line 565:

if (!$data) {
            return array('value' => $finalValues, 'error' => $errors);
        }

https://www.dropbox.com/s/7zy3mzykzsrtlk9/Screenshot 2017-09-20 07.57.05.png?dl=0

#2

Est Digital

That does not seem to do anything than just placing the errors 4 rows lower.

#3

BoldMinded (Brian)

Try changing it to

if (!$data || empty($data)) {
            return array('value' => $finalValues, 'error' => $errors);
        }
#4

Est Digital

I solved those errors with a check: I used print_r for checking the value of $data. There seemed to be a random space in there. So with: if ($data != ” “) { return array(‘value’ => $finalValues, ‘error’ => $errors); } It was solved. 1 error remained, but that is not Bloqs related (I think).

#5

Est Digital

Seems the last error was there yesterday just because I only did a refresh of the page and not run the import again. All works fine now! Thanks for bringing me on the right path!

So the solution is on the same place as you were going to put it but like this: if ($data != ” “) { return array(‘value’ => $finalValues, ‘error’ => $errors); } Just to be sure, the others could be added: if ($data != ” “ || !$data || empty(!$data) || $data == “”) { return array(‘value’ => $finalValues, ‘error’ => $errors); } Thanks again!

#6

BoldMinded (Brian)

Ok, I’ll make this update for the next release. I had to make a very similar change to a custom add-on a few months ago but I can’t for the life of me remember what specific add-on I made the change to, but that $data != ” ” thing is totally ringing a bell 😊

Glad we got it sorted out and everything is working for you again.

#7

BoldMinded (Brian)

Wait, wouldn’t it be:

if ($data == " ")

If its a blank 1 character string then its not an array, so we want it to return nothing and not process the foreach loop below.

#8

Est Digital

Oh, haha.

Seems I totally wrote it wrong here!

It indeed is supposed to be:

if (!$data || empty($data) || $data == ” ” || $data == “NULL” || !isset($data)) { return array(‘value’ => $finalValues, ‘error’ => $errors); }

I added the other empty checks just in case, I’ve had different cases where one will work and the other won’t, happens a lot. So now it will work no matter what happens!

#9

BoldMinded (Brian)

Ok, cool. Thanks for verifying 😊

#10

BoldMinded (Brian)

Another simpler check may be to try

if (!$data || !is_array($data)) {

#11

Est Digital

That also seems to work! 😊

#12

BoldMinded (Brian)

Yeah, its a little cleaner. Cool, I’ll go with that for the next release. Thanks for verifying!

Login to reply