Introduction

When WP_DEBUG and WP_DEBUG_LOG are enabled in WordPress, deprecated function warnings can flood the debug.log file, causing it to grow to several gigabytes in hours. Each page load may trigger dozens of identical warnings from outdated plugins or themes:

bash
PHP Deprecated:  Function wp_make_content_images_responsive is deprecated since version 5.5.0!
PHP Deprecated:  Function create_function() is deprecated since version 7.2.0!
PHP Deprecated:  Methods with the same name as their class will not be constructors in a future version of PHP

This fills disk space and makes it impossible to find meaningful debug information.

Symptoms

  • debug.log file grows to multiple gigabytes within hours or days
  • Disk space fills up, potentially causing site outage
  • Log file contains thousands of identical deprecation warnings
  • Hard to find actual errors among the noise
  • Site performance degrades from constant file I/O writing to the log

Common Causes

  • WP_DEBUG enabled in production environment
  • Old plugins or themes using deprecated WordPress functions
  • PHP version upgrade deprecates functions that were previously valid
  • No log rotation configured for debug.log
  • Plugin calls deprecated function on every page load (in a tight loop or global scope)

Step-by-Step Fix

  1. 1.Identify the source of the deprecation warnings:
  2. 2.```bash
  3. 3.# Find the most common deprecation messages
  4. 4.awk '/Deprecated/' /var/www/html/wp-content/debug.log | sort | uniq -c | sort -rn | head -10
  5. 5.`
  6. 6.Disable WP_DEBUG in production. Edit wp-config.php:
  7. 7.```php
  8. 8.// Disable debug logging in production
  9. 9.define('WP_DEBUG', false);
  10. 10.define('WP_DEBUG_LOG', false);
  11. 11.define('WP_DEBUG_DISPLAY', false);

// Or log only actual errors, not deprecation warnings define('WP_DEBUG', true); define('WP_DEBUG_LOG', true); define('WP_DEBUG_DISPLAY', false); @ini_set('log_errors', 'On'); @ini_set('error_reporting', E_ALL & ~E_DEPRECATED & ~E_NOTICE); ```

  1. 1.Suppress specific deprecation warnings at the PHP level. Create a mu-plugin at wp-content/mu-plugins/suppress-deprecations.php:
  2. 2.```php
  3. 3.<?php
  4. 4.// Suppress specific deprecated function warnings
  5. 5.set_error_handler(function($errno, $errstr, $errfile, $errline) {
  6. 6.$deprecated_patterns = [
  7. 7.'wp_make_content_images_responsive',
  8. 8.'create_function',
  9. 9.'Function name must be a string',
  10. 10.];
  11. 11.foreach ($deprecated_patterns as $pattern) {
  12. 12.if (strpos($errstr, $pattern) !== false) {
  13. 13.return true; // Suppress this warning
  14. 14.}
  15. 15.}
  16. 16.return false; // Let PHP handle other errors normally
  17. 17.}, E_DEPRECATED | E_USER_DEPRECATED);
  18. 18.`
  19. 19.Truncate the existing log file to reclaim disk space:
  20. 20.```bash
  21. 21.truncate -s 0 /var/www/html/wp-content/debug.log
  22. 22.# Or
  23. 23.echo "" > /var/www/html/wp-content/debug.log
  24. 24.`
  25. 25.Set up log rotation for debug.log:
  26. 26.`
  27. 27./var/www/html/wp-content/debug.log {
  28. 28.daily
  29. 29.rotate 7
  30. 30.compress
  31. 31.missingok
  32. 32.notifempty
  33. 33.create 640 www-data www-data
  34. 34.}
  35. 35.`
  36. 36.Update or replace the offending plugins/themes that trigger deprecation warnings:
  37. 37.```bash
  38. 38.wp plugin list --format=csv | grep -i "inactive|update"
  39. 39.wp core update
  40. 40.wp plugin update --all
  41. 41.`

Prevention

  • Never leave WP_DEBUG enabled in production unless actively debugging a specific issue
  • Use error_reporting(E_ALL & ~E_DEPRECATED & ~E_NOTICE) to filter out noise while still catching real errors
  • Set up log file size monitoring and alerting:
  • ```bash
  • find /var/www/html/wp-content -name "debug.log" -size +100M -exec ls -lh {} \;
  • `
  • Keep plugins and themes updated to their latest versions
  • Test plugin compatibility with new PHP versions before upgrading
  • Use a log management service (Papertrail, Loggly) that handles rotation and search automatically
  • Add debug log size check to your server monitoring dashboard