0

My error log is showing many instances of: PHP Warning: Invalid argument supplied for foreach() in \wp-admin\includes\plugin.php on line 1415

How do I go about determining which plugin (and which page/line of that plugin) is causing this? Is there a mechanism in place, or do I have to trial and error it?

  • Deactivate one plugin at a time. I usually do a half split, deactivating half, if problem still exists deactivate another half of the active ones. Make sure to take note of which ones were active. – stoi2m1 Jul 21 '16 at 23:14
  • @jungalist Start with the basic debugging configuration for WordPress, and then let us know if you run into any more difficulty =] – bosco Jul 21 '16 at 23:30
  • Are you able to get stack traces? PHP Debuggers and tools such as xdebug will allow you to see the call stack and trace it back through each function – Tom J Nowell Jul 21 '16 at 23:31
  • I will try these suggestions and report back. Thank you for the input, each of you. – jungalist Jul 22 '16 at 1:56
2

In your wp-config.php make sure to include;

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_DISPLAY', true );

Sometimes your environment will do a better job at outputting the stack trace.

If that doesn't work, you can go that line in WP core and add;

$backtrace = debug_backtrace();

print('<pre>');
print_r ( $backtrace );

That should give you a lot more information to go off of, for example;

/*
Array
(
    [0] => Array
        (
            [file] => /site/wp-content/plugins/debug-bar-console/class-debug-bar-console.php
            [line] => 84
            [function] => eval
        )

    [1] => Array
        (
            [function] => ajax
            [class] => Debug_Bar_Console
            [object] => Debug_Bar_Console Object
                (
                    [_title] => Console
                    [_visible] => 1
                )

            [type] => ->
            [args] => Array
                (
                    [0] => 
                )

        )

    [2] => Array
        (
            [file] => /site/wp-includes/plugin.php
            [line] => 525
            [function] => call_user_func_array
            [args] => Array
                (
                    [0] => Array
                        (
                            [0] => Debug_Bar_Console Object
                                (
                                    [_title] => Console
                                    [_visible] => 1
                                )

                            [1] => ajax
                        )

                    [1] => Array
                        (
                            [0] => 
                        )

                )

        )

    [3] => Array
        (
            [file] => /site/wp-admin/admin-ajax.php
            [line] => 89
            [function] => do_action
            [args] => Array
                (
                    [0] => wp_ajax_debug_bar_console
                )

        )

)
*/
| improve this answer | |
0

Since it is just debugging you could temporarily edit the function in plugins.php which is throwing the error and put in the first line of that function:

echo "<!--"; var_dump(func_get_args()); echo "-->";

Then view the page source it should let you know more and the debug info will be output above the error messages they relate to. And of course remove the line when you are done.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.