Back to Community

Resolving Common PHP Deprecation and Error Notices in Newsletter Plugin

Content

Users of the 'Newsletter – Send awesome emails from WordPress' plugin sometimes encounter PHP deprecation notices or error messages, especially when using newer versions of PHP or with WordPress debugging enabled. These issues are often related to outdated PHP functions or incorrect database query preparation. This guide explains the most common causes and how to resolve them.

Common Issues and Their Solutions

1. PHP 8.1 Deprecation: strftime()

The Problem: With PHP 8.1, the strftime() function is deprecated. You may see an error referencing a file like /statistics/index.php on line 39.

The Solution: This specific issue was confirmed by the 'Newsletter – Send awesome emails from WordPress' team to be fixed in a recent plugin update. The first step is always to update the plugin to the latest available version. If the error persists after updating, it may be a caching issue; try clearing any server or WordPress cache.

2. WordPress prepare() Called Incorrectly

The Problem: A common notice appears when WP_DEBUG is enabled: "Notice: wpdb::prepare was called incorrectly. Not supported ValueType (array)". This often happens during operations like sending a test email. This notice is related to how database queries are prepared for security.

The Solution: The plugin's development team has been made aware of this pattern in their code. While their usage may be functionally correct, WordPress core recommends moving away from unquoted values in $wpdb->prepare(). As a user, your best course of action is to ensure you are running the latest version of the plugin, as the developers are actively working to modernize their code for future WordPress versions. If you are a developer extending the plugin, avoid passing arrays to the prepare() method.

3. Function create_function() is deprecated

The Problem: Users on PHP 7.2+ may see a deprecation notice for create_function(), which is often triggered when sending an email.

The Solution: According to the 'Newsletter – Send awesome emails from WordPress' team, this deprecated function is not used in their core plugin. This error is most likely originating from another plugin on your site, such as an SMTP plugin that integrates with the newsletter functionality. To identify the culprit, deactivate all other plugins temporarily and then reactivate them one by one while testing to see which one causes the error to reappear.

4. "Module 'sqlite3' already loaded" Error

The Problem: An error stating that the 'sqlite3' module is already loaded when using PHP 7.4, preventing test emails from being sent.

The Solution: The plugin's developers have stated they do not use SQLite. This error is almost certainly a conflict with another plugin or a server configuration issue. The fact that reverting to PHP 7.3 resolved the issue for one user suggests a compatibility problem with a specific PHP 7.4 configuration. Troubleshoot by deactivating other plugins to find the one causing the module conflict, or consult your web hosting provider about the PHP configuration.

General Troubleshooting Steps

  • Update Everything: Always ensure WordPress, your theme, and all plugins (especially the Newsletter plugin) are updated to their latest versions. Many bugs and deprecations are patched in updates.
  • Conflict Test: If an error persists, perform a conflict test. Temporarily switch to a default WordPress theme (like Twenty Twenty-Four) and deactivate all plugins except 'Newsletter'. If the error disappears, reactivate your themes and plugins one by one to find the source of the conflict.
  • Check Debug Log: For detailed error information, enable WordPress debugging and check the wp-content/debug.log file for specific error messages and their origins.

By following these steps, you can diagnose and resolve the most common PHP and WordPress notice errors related to the Newsletter plugin.