Bright Labs

Which plugin is causing the PHP deprecated warnings in your WordPress log? How to find it

Your debug.log keeps filling up with Deprecated lines, and you want to know which plugin or theme is writing them. Start with the file path in each notice. If it runs through a plugin or theme folder under wp-content, start with that plugin or theme. If it points into wp-includes, that file may only be the trigger, not the source. In that case, search your plugin and theme code for the function the notice names, or turn plugins off one at a time until the notice stops.

Below: how to get the notices into a log, how to read them, and what to do when the path doesn't give you the answer.

Turn on the debug log so you can read the notices

WP_DEBUG is off unless you turn it on. The WordPress debugging guide says "It is assumed to be false by default". Its companion, WP_DEBUG_LOG, causes all errors to also be saved.

When WP_DEBUG_LOG is true, the log is saved to debug.log in the content directory. You can also set it to a valid file path to keep the file somewhere else. Watch the dependency, because it's easy to miss: for WP_DEBUG_LOG to do anything, WP_DEBUG must be enabled (true).

The guide also pairs WP_DEBUG_DISPLAY set to false with the log. It says that setting should be used with WP_DEBUG_LOG so that errors can be reviewed.

Example you write in wp-config.php (the three settings described above)
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

The catch: the guide is clear that this isn't for production. In its words, "It is not recommended to use WP_DEBUG or the other debug tools on live sites". Do this on a staging copy if you have one, and switch it back off when you're done.

Read the path in each notice

Deprecation notices can come from PHP itself or from WordPress, so it helps to tell them apart.

PHP's own notices are E_DEPRECATED. The PHP manual describes them as "Run-time deprecation notices. Enable this to receive warnings about code that will not work in future versions." There's also E_USER_DEPRECATED, which the manual calls a user-generated deprecation message that is generated in PHP code.

WordPress adds its own. The debugging guide says enabling WP_DEBUG also causes notices about deprecated functions and arguments within WordPress. Those notices often indicate the new function that should be used instead, so read the whole line before you go searching.

What to do based on where the notice's path points
The path runs throughWhere to lookWhat to do next
wp-content/plugins/ and then a folderThe plugin in that folderUpdate it, then check whether the notice comes back
wp-content/themes/ and then a folderThe theme in that folderUpdate it, then check whether the notice comes back
wp-includes/Whatever called the WordPress function the notice namesSearch your plugins and themes for that function name

That last row is the one that trips people up. In a WordPress.org support thread, a site owner had a notice saying get_currentuserinfo was deprecated and to use wp_get_current_user() instead. The path pointed at wp-includes/functions.php. As they put it, "this function.php is only the trigger of this notice, but not its source." So the path alone didn't show where the old call came from.

Search the code for the deprecated function

When the notice names a WordPress function and points into wp-includes, search for that function name. The forum moderator's answer in that thread: "If you have SSH access to your site, you can use grep".

Example you write (run from your WordPress folder; use your notice's function)
grep -r get_currentuserinfo wp-content/plugins wp-content/themes

For each file it finds, look at the folder name right after plugins/ or themes/. That's the plugin or theme to check. If several plugins match, check which ones are active first.

No SSH? Isolate it instead. The moderator's fallback in the same thread: "Please attempt to disable all plugins, and use one of the default (Twenty*) themes." Then, "If the problem goes away, enable them one by one to identify the source of your troubles." Load a page after each step and check the end of debug.log.

The Health Check plugin on WordPress.org has a troubleshooting mode for this. Its page says troubleshooting gives you "a clean WordPress session, where all plugins are disabled", and that a default theme is used, "but only for your user until you disable it or log out." A staging copy is still the safer place to do it if you have one.

Find PHP deprecations before they reach the log

If your notices are PHP deprecations that showed up after a PHP upgrade, you can also look for them before the switch. We make a free WordPress plugin for this, Bright Labs Compatibility Scanner for PHP. It reads the code of every installed plugin and theme. Then it lists each file and line that uses something removed or deprecated in the PHP version you pick, from PHP 8.2 to 8.5.

The scan runs inside WordPress in short steps and needs no shell access. It reads code without running it, so it can miss problems in code that's built at runtime and can flag code that never runs. If you want a running record instead, the Pro plan ($9/month per site) adds a log of PHP deprecation notices by plugin.

Once you know which plugin it is

Sources

Questions

Do deprecated notices mean my site is broken right now?

The PHP manual describes E_DEPRECATED as warnings about code that will not work in future versions. So treat them as a to-do list for your next upgrade, and fix them before you move to a newer version.

The notice points to wp-includes/functions.php. Is WordPress core the problem?

Not necessarily. In the WordPress.org support thread this post cites, the notice pointed at wp-includes/functions.php, and the poster said that file was only the trigger, not the source. Search your plugins and themes for the function name in the notice to find what's calling it.

Can I leave WP_DEBUG on to keep watching the log?

The WordPress debugging guide doesn't recommend using WP_DEBUG or the other debug tools on live sites. Turn it on on a staging copy, or briefly on live while you trace the notice, then turn it off again.

Will hiding the notices fix them?

No. The guide says WP_DEBUG_DISPLAY set to false should be used with WP_DEBUG_LOG so that errors can be reviewed. Hiding notices doesn't change the code: the deprecated calls stay until the plugin or theme is updated or fixed.

Related