WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [closed] Invalid argument supplied for foreach()..... (32 posts)

  1. pilatomic
    Member
    Posted 4 months ago #

    hello,
    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/pila.fr/site/www/wordpress/wp-includes/plugin.php 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 http://pila.fr/wordpress/?feed=rss2 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 ?

  2. tomgeijn
    Member
    Posted 4 months ago #

    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.

  3. Gospodin_I
    Member
    Posted 4 months ago #

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

    Haven't seen any other effect.

  4. geerthoekzema
    Member
    Posted 4 months ago #

    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:
    http://make.wordpress.org/core/2014/04/14/symlinked-plugins-in-wordpress-3-9/

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

  5. pilatomic
    Member
    Posted 4 months ago #

    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

  6. Alin Ionut
    Member
    Posted 4 months ago #

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

  7. yay-food
    Member
    Posted 4 months ago #

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

  8. Evan Herman
    Member
    Posted 4 months ago #

    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.

  9. yay-food
    Member
    Posted 4 months ago #

    @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.

  10. mc_marie
    Member
    Posted 4 months ago #

    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.

  11. pilatomic
    Member
    Posted 4 months ago #

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

  12. Gospodin_I
    Member
    Posted 4 months ago #

    What exactly do you mean by 'manual method'? As I said earlier, I updated using WP-CLI...

  13. pilatomic
    Member
    Posted 4 months ago #

    Copying the new files through FTP

  14. Daniel
    Member
    Posted 4 months ago #

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

  15. Samuel Wood (Otto)
    Tech Ninja
    Posted 4 months ago #

    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.

  16. Anton Timmermans
    Member
    Posted 4 months ago #

    @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.

  17. Samuel Wood (Otto)
    Tech Ninja
    Posted 4 months ago #

    Additionally: Did anybody having this problem do an automatic update, or is it all cases of manual updates?

    If you manually updated, did you also make sure to replace ALL the files? Including the main files in the WordPress root directory?

    Specifically, I can see how you might get this error if you failed to replace the wp-settings.php file with the newer version from 3.9.

    So make sure you upgraded ALL the files. If necessary, the Updates screen in WordPress has a "Reinstall" button that will replace all the WordPress files with correct copies. You can use this to make sure all the files have been updated.

  18. Samuel Wood (Otto)
    Tech Ninja
    Posted 4 months ago #

    @atimmer I'm aware of the WP_DEBUG setting, however disabling display_errors on live sites is always a good idea. It should be done across the entire system, and not just relying on WordPress to do it for you.

  19. Anton Timmermans
    Member
    Posted 4 months ago #

    I update the submodule using the following method:

    • Remove all the files (except the .git) in the working copy of the submodule.
    • Download a new WordPress copy from http://nl.wordpress.org.
    • Copy all downloaded files in the working copy
    • Commit this with a nice commit message, such as "WordPress 3.8.3 -> 3.9"
    • Tag this commit with the correct WordPress function, such as "tag -a 3.9"

    In a project that has the submodule I then go to the WordPress folder, do "git fetch" and "git checkout 3.9". It is a completely clean 3.9 installation of WordPress except for the database.

  20. Samuel Wood (Otto)
    Tech Ninja
    Posted 4 months ago #

    @atimmer If you're only getting the issue with WP-CLI, you may need to update WP-CLI:

    See
    https://github.com/wp-cli/wp-cli/pull/1019
    https://github.com/wp-cli/wp-cli/issues/1020

  21. NaomiLiz
    Member
    Posted 4 months ago #

    I have the same message. It won't allow me to log into my dashboard, either.

  22. pilatomic
    Member
    Posted 4 months ago #

    Samuel, you got it right ! I just forgot to copy the wp-settings.php file.
    Now everything is fine !
    Thx

  23. Samuel Wood (Otto)
    Tech Ninja
    Posted 4 months ago #

    @pilatomic Glad that worked for you, but make sure you update ALL the files. Any missed files anywhere could cause issues.

  24. mc_marie
    Member
    Posted 4 months ago #

  25. huxleydias
    Member
    Posted 3 months ago #

    Hello guys, I had the same problem, and resolved as follows:
    My theme was custom post types, some with "taxonomies" other not defined, then the post types that did not have a value of "taxonomies" defined custom I removed / commented out the line and solved the problem.
    Hope that helps!

    Olá pessoal, tive o mesmo problema, e resolvi da seguinte maneira:
    Meu tema tinha custom post types, alguns com "taxonomies" definidos outros não, então os custom post types que não tinha um valor de "taxonomies" definidos eu removi/comentei a linha e resolveu o problema.
    Espero que ajude!

  26. cbahida@gmail.com
    Member
    Posted 3 months ago #

    Same here.

    i just removed

    foreach ( $wp_plugin_paths as $dir => $realdir ) {
    if ( strpos( $file, $realdir ) === 0 ) {
    $file = $dir . substr( $file, strlen( $realdir ) );
    }
    }

    from plugin.php line 622 and it works...

  27. DamienWilson
    Member
    Posted 2 months ago #

    I've set up a local dev environment and just came across this issue.

    I fixed it by syncing the local plugins folder with the live version.

    The database keeps track of all the active plugins and if the plugin isn't there this error will occur.

  28. popgirl23
    Member
    Posted 2 months ago #

    Simply replacing wp-settings.php fixed it for me. Thank you.

  29. KTS915
    Member
    Posted 1 month ago #

    @cbahida

    Thanks very much! Commenting out those lines worked for me too!

    In the longer term, though, won't this get overridden by a WordPress update? If so, does anyone have a longer term fix?

  30. jazzquist
    Member
    Posted 1 month ago #

    Try Updating your PHP Version to PHP 5 if its not that already

    I am not sure if this is the case but this problem seems to occur a number of times when migrating wordpress sites or migrating dynamic sites in general. If this is the case make sure the hosting you are migrating to uses the same PHP version your old site uses.

    If you are not migrating your site and this is just a problem that has come up try updating to PHP 5. This takes care of some of these problems. Might seem like a silly solution but did the trick for me.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.