Back to Community

Resolving PHP 8.4 Deprecation Warnings in WP-Optimize

5 threads Sep 9, 2025

Content

Users updating to newer versions of PHP, particularly PHP 8.4, may encounter deprecation warnings related to the WP-Optimize plugin. These warnings appear in server error logs and can be concerning, though they typically do not break site functionality. This guide explains the cause and provides a solution.

Understanding the Problem

The specific warning often looks like this:

PHP Deprecated: Updraft_Logger::__construct(): Implicitly marking parameter $logger as nullable is deprecated, the explicit nullable type must be used instead in /wp-optimize/includes/class-updraft-logger.php on line 24

This is a deprecation notice, not a fatal error. It is triggered because PHP 8.4 has introduced stricter coding standards. The warning indicates that the old method of making a function parameter nullable by giving it a default value of null is now outdated. The new standard requires using an explicit nullable type, denoted by a question mark (?) before the type declaration.

The Solution

Based on community reports and analysis, the fix involves a simple code change to the plugin file. It is important to note that modifying plugin files directly is a temporary workaround; any changes may be overwritten when the plugin is updated. The official WP-Optimize team is aware of this issue and is expected to release an update with a permanent fix.

How to apply the fix:

  1. Access your website's files via FTP, SFTP, or your hosting provider's file manager.
  2. Navigate to the WP-Optimize plugin directory: /wp-content/plugins/wp-optimize/.
  3. Locate and open the file: includes/class-updraft-logger.php.
  4. Find line 24, which contains the constructor method:
    public function __construct(Updraft_Logger_Interface $logger = null)
  5. Edit this line to use the explicit nullable type syntax:
    public function __construct(?Updraft_Logger_Interface $logger = null)
  6. Save the file and upload it back to your server, overwriting the old one.

Important Considerations

  • Backup First: Always create a full backup of your site, including its files and database, before making any changes.
  • Temporary Nature: This is an interim solution. The official plugin update will be the proper, long-term fix.
  • Error Logs: After applying the change, monitor your error logs to confirm the warning has ceased.

By implementing this change, you can resolve the deprecation warning and ensure your error logs remain clean while waiting for the official plugin update.