WordPress Plugin: Log Deprecated Calls

This is a pretty straightforward plugin for WordPress that is of particular interest to fellow plugin authors. (Theme authors too!)

As WordPress changes over time, old functions and files are sometimes replaced with new ones. There is generally a transitional period during which the old functions (and files) are “deprecated”, which is basically an official statement to the effect of:

This function may go away in a future version of WordPress. It works for now, but you should really switch to using such-and-such new function instead, or your plugin/theme will stop working after some future update.

There is a functionality built-in to WordPress that allows you to flag deprecated functions, but it’s not terribly informative, and thus not very useful for plugin authors.

The plugin on this page, when activated, puts an entry in your PHP log any time a deprecated function is called, a deprecated file is included, or a deprecated argument is used when calling a function. The entry is far more useful than the default WordPress log notice — this one tells you the name of the function, the exact file that called it, the line the call was on, and what new function, if any, you should use instead. It looks something like this:

WordPress: The ***deprecated function*** "some_old_function" was called from wp-content/plugins/myplugin/myplugin.php on line 170. Use "some_new_function" instead.

By default, it logs deprecated calls to the PHP error log. There is an admin screen (under the Plugins menu) that lets you toggle logging to the database, which, if activated, allows you to see the log on that same admin screen.

For plugin authors, it also serves as an example of how to use the new uninstall functionality coming up in WordPress 2.7. Simply put: if you use the Plugin Management page to delete this plugin, it will first clean up everything it did in the system, including clearing options, deleting the log table, and so forth….


Please Note: This plugin is also available from GitHub: https://github.com/strider72/log-deprecated-calls GitHub version is having issues. Hopefully fixed soon!

Otherwise, here’s the direct link. Have at it!

Log Deprecated Calls v1.3

27 Responses to WordPress Plugin: Log Deprecated Calls

  1. Pingback: Daily Digest for June 12th

  2. Pingback: New Plugin: Log Deprecated Notices | Andrew Nacin

  3. Pingback: Our WordPress Developer Toolbox | Geek is a Lift-Style.

  4. WAon, Very Usefull. Thank wp log deprecated developer :)

  5. Pingback: Elegant Design: A Case Study | Nerdaphernalia

  6. Stephen R says:

    There’s a new update — version 1.2. If you haven’t updated in a long time, this version is worth getting, as i recently added support for deprecated arguments in addition to functions and files.

    Note that there’s a change to the database structure, so your deprecated log will be reset.

    If you updated very recently, there’s an important bug fix.

    More to come. In the near future this should either become part of WordPress Extend (yay! automatic updates!), or have its own update mechanism built in (yay! Automatic updates!). Before that happens I want to improve database efficiency — right now it’s relatively bloated.

  7. Stephen R says:

    New update — 1.3 greatly improves database efficiency.

Leave a Reply

Your email address will not be published.