Invalid argument supplied for foreach()
-
Hi,
Since upgrading to 4.7.0.9 I’m now getting PHP warnings in an error_log.
PHP Warning: Invalid argument supplied for foreach() in
wp-content/plugins/wordpress-popup/inc/class-popup-base.php on line 638
-
Hey there mcolli10,
Hope you’re well today!
I’ve tested this on my sandbox site and I’m not being able to see the error, could you please try using default WordPress theme like Twenty Fifteen and deactivating all other plugins as displayed in the following flowchart to know which theme/plugin is conflicting if any.
http://premium.wpmudev.org/wp-content/uploads/2013/12/Support-Process-Support-Process.png
Best regards,
BojanSame here. Updated to the latest version of the pop up plugin and got:
Warning: Invalid argument supplied for foreach() in /homepages/46/d388355453/htdocs/www/swws.org.pl/wp-content/plugins/wordpress-popup/inc/class-popup-base.php on line 638Updated WP to 4.2.2 and still get the same warning…
For now, I’ve disabled the plugin.
Hi Bojan,
I did some further research and found an interesting article about the PHP Warning I’m getting. This site http://sarathlal.com/fix-for-php-warning-invalid-argument-supplied-for-foreach-in/ explains this well. I followed solution 2
I changed the line #638 from
foreach ( $popup_ids as $id ) {
to
foreach ( (array) $popup_ids as $id ) {
and the PHP warnings have stopped.Regards
MichaelHey there Michael,
Thanks for taking time to post a solution, you’re awesome!
I’ve tested additionally on another install and for some reason I’m not being able to see this warning but since you as well were having the problem I’ll definitely report this to our developer and suggest your solution so it might be implemented into the following version of the plugin.
@nashaden can you please try using the solution from Michael to see if that will fix the warning for you?
Have a great day!
Cheers,
BojanI also have this issue!
After updating to 4.7.0.9 I get this warning message displayed in the top row of my blog!Warning: Invalid argument supplied for foreach() in /storage/content/92/124892/blog.ingredientmatcher.com/public_html/wp-content/plugins/wordpress-popup/inc/class-popup-base.php on line 638
How do I get to the code to change according to solution by Michael?
Shouldn’t this be fixed directly in the plugin code instead?
Hey there IngredientMatcher,
As I mentioned above I’ve reported this to our developer and this will most likely be added in the next plugin update.
You can change the line in the code now in order to remove the warning. To do so please download class-popup-base.php which is located in /wp-content/plugins/wordpress-popup/inc/class-popup-base.php and edit the line on 638 as mentioned above.
Best regards,
BojanHi again,
I am sorry but I don’t understand how I can download class-popup-base.php?If I enter the url: http://blog.ingredientmatcher.com/wp-content/plugins/wordpress-popup/inc/class-popup-base.php i get an error message.
Can I do this from the web admin interface of wordpress? Or do I need to download some FTP program and try to set that up first?
Hey again IngredientMatcher,
Sorry about my instructions not being clear enough 🙁
This can’t be done from WordPress admin panel, you’ll have to access your WordPress installation files on your server. You can do that either by accessing your site via cPanel or for example by using an FTP client such as FileZilla that allows you to connect to your server and browse through files.
Once you’re there you should be able to see /wp-content/ in the foot folder of your site and from there you should be able to navigate to that file.
Hope this helps 🙂
Best regards,
Bojan
The topic ‘Invalid argument supplied for foreach()’ is closed to new replies.