Support » Fixing WordPress » Invalid argument supplied for foreach()…..

  • Resolved pilatomic


    i just updated my website to wordpress 3.9, and i keep getting a lot of these messages on top of each page :
    Warning: Invalid argument supplied for foreach() in /flex/domain/ on line 622

    With all plugin deactivated (I renamed the plugins folder to be sure) i just get the message 4 times, but each plugin I reactivate increase the number of time this message is displayed.

    The same problems seems to prevent the display of the RSS feed page : just go to to see what it looks like.

    I just looked inside the plugin.php file, and this seems to be the section causing troubles :

    function plugin_basename( $file ) {
    	global $wp_plugin_paths;
    	foreach ( $wp_plugin_paths as $dir => $realdir ) {
    		if ( strpos( $file, $realdir ) === 0 ) {
    			$file = $dir . substr( $file, strlen( $realdir ) );
    	$file = wp_normalize_path( $file );
    	$plugin_dir = wp_normalize_path( WP_PLUGIN_DIR );
    	$mu_plugin_dir = wp_normalize_path( WPMU_PLUGIN_DIR );
    	$file = preg_replace('#^' . preg_quote($plugin_dir, '#') . '/|^' . preg_quote($mu_plugin_dir, '#') . '/#','',$file); // get relative path from plugins dir
    	$file = trim($file, '/');
    	return $file;

    I don’t really know PHP, so i just can’t explain myself what is going wrong. Could you help me ?

Viewing 15 replies - 1 through 15 (of 31 total)
  • I’m having the same error.
    I certainly hope that somebody knows how to fix this.
    It is possible for me to replace the plugin.php with an older version, but then I seemed to be unable to activate new plugins.

    Got the same message when I tried to upgrade to 3.9 using wp-cli.

    Haven’t seen any other effect.

    Same error here.

    We maintain about 30 to 40 sites. But only one is erroring after the update. No idea why and how to solve it. So if anyone have some suggestions, i’d like to hear it.

    It probably have something to do with this function:

    Maybe some security settings? Still trying to figure this out.

    Up to now, i didn’t find how to fix it.
    Since my web hosting has a backup function, i just restored a backup of the site to cancel the update.
    I will wait for a fix or a workaroung before updating to 3.9

    Same here, I’ll downgrade to backup until problem is fixed.

    I have the same error as well. Hopefully a fix or workaround will be on the way…

    I haven’t faced this issue and updated to WordPress 3.9 an hour after it was released.

    Have you tried deactivating ALL plugins and switching to a default theme to test it?

    I’d almost guarantee its from a plugin author not properly preparing for the 3.9 update.

    @evan — you know, it would be swell if you didn’t presume the rest of us didn’t know what we were doing.

    I have no installed plugins except akismet.

    I have no installed themes except twentythirteen.

    Oddly, all my other WP installations updated fine, without this error. But one of them has the error, and even after reinstalling WP repeatedly, the error is still there.

    It’s not about the plugins or the themes. It’s about something else.

    BTW, that you did not have a problem is no proof that other people didn’t or shouldn’t have it.

    I too experienced this, but only when I did the manual upgrade for one of my clients. The one-click update on two of the other sites I’ve worked on lately didn’t do it.

    Interesting, since I also updated wordpress using the manual method.

    What exactly do you mean by ‘manual method’? As I said earlier, I updated using WP-CLI…

    Copying the new files through FTP

    Same here, only site I updated manually through FTP gives this error.

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    To solve the problem immediately, you need to disable the display_errors setting on your web hosting account. This is a PHP setting that makes it display potential errors and other such things. Note that the reported issue is a “Warning” and not an actual error. The code actually works fine, it’s just that when you have debugging turned on, you’ll get this spurious message.

    Normally, live websites on the public internet should not have error displays enabled in the first place. It’s not a safe thing to do.

    So ask your web host how to disable the PHP display_errors setting. This may require editing a PHP.INI file or an .htaccess file.

    @samuel, you can achieve the same by just setting WP_DEBUG on false in the wp-config.php.

    I can confirm this warning in our development environment. We update WordPress using a submodule with the dutch version of WordPress in it. I only see this error with wp-cli and not in the WordPress admin. Nevertheless I really dislike warnings and notices and would like it if this was fixed.

Viewing 15 replies - 1 through 15 (of 31 total)
  • The topic ‘Invalid argument supplied for foreach()…..’ is closed to new replies.