• Resolved pilatomic

    (@pilatomic)


    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 https://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 ?

Viewing 15 replies - 16 through 30 (of 31 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    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.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

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

    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 https://nl.www.remarpro.com.
    • 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.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    @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

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

    Thread Starter pilatomic

    (@pilatomic)

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

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

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

    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!

    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…

    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.

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

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

    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.

    @jazzqist

    I am already on PHP 5.5, so that’s not the cause of the issue for me.

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