If your using a view without any content you get the following error :

warning: Invalid argument supplied for foreach() in /home/drayen/work/code/acmconsulting.eu/public_html/sites/all/modules/panels/panels_views/panels_views.module on line 699.

Attached a simple diff patch to fix this.

Comments

wim leers’s picture

Status: Needs review » Needs work

Proper patches, please: http://drupal.org/patch/create.

Soren Jones’s picture

StatusFileSize
new3.06 KB

I was receiving the same foreach() warning on the patched line and on two other lines. An updated patch is attached.

merlinofchaos’s picture

A simpler patch would be to make sure $pv->contexts is always an array() when the object is created/loaded -- and this is also more in line with how the rest of Panels operates.

Soren Jones’s picture

StatusFileSize
new2.34 KB

Okay. Thank you. Like this?

yched’s picture

StatusFileSize
new748 bytes

I solved this using a simpler patch - prevents records with contexts = "N;" from entering the {panels_views} table.
Not sure this is the cleanest way to do this, though. At least you can pick :-)

yched’s picture

Status: Needs work » Needs review

status

Soren Jones’s picture

Thank you. Unfortunately your patch (in comment #5) doesn't work for me. I receive the same foreach() warning as without the patch, just moved down a line from 699 to 700. Any thoughts why?

yched’s picture

That's because the patch in #5 doesn't automatically fix your existing panels_views. You need to resave them (no need to change anything)

Soren Jones’s picture

Perfect. Thank you! I'm using your #5 patch.

nath’s picture

Works for me as well. :)

merlinofchaos’s picture

Status: Needs review » Reviewed & tested by the community

Patch in #5 is exactly how I do it elsewhere. Thanks! I'll commit this fairly soon.

merlinofchaos’s picture

Status: Reviewed & tested by the community » Fixed

Committed! THanks for the work on this!

jmai’s picture

I just tried the latest CVS today, unfortunately, I am getting the error above. But when I apply patch #4, I don't get the warnings.

yched’s picture

@jmai : see #8 above - "That's because the patch in #5 (the one that got committed) doesn't automatically fix your existing panels_views. You need to resave them (no need to change anything)"

jmai’s picture

Sorry I wasn't detailed explaining my problem. I did resave and I don't get the warnings anymore, except only when I configure the Mini panels on the content page. That is strange.

alanbold’s picture

How do you apply the patch? thanks

yched’s picture

alanbold : the patch has already been committed (see comment #11), so you don't need to apply it manually, simply grab latest 5.x-2.x-dev release (http://drupal.org/node/128199)
for general instructions on how to apply patches, see http://drupal.org/patch

timmillwood’s picture

This has fixed my 699 error I now have a line 701 and 739 error.

Any ideas?

merlinofchaos’s picture

jmai, timmilwood: Those might be different problems. Please open new issues with specifics. Thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.