This commit is contained in:
Javier Casares 2026-02-18 16:07:17 +00:00
commit 64b13fe7aa
5 changed files with 74 additions and 11 deletions

View file

@ -1,3 +1,16 @@
= 2.2.6 =
* CRITICAL FIX: Worker now suppresses plugin header warnings in MultiSite environments
* CRITICAL FIX: Fixed Newsletter base class dependencies not loading in DOING_CRON context
* CRITICAL FIX: Worker now manually initializes plugin when newsletter_loaded hook doesn't fire
* CRITICAL FIX: Fixed MultiSite subdirectory site detection - worker now correctly loads site from --url path
* CRITICAL FIX: Removed WP_CLI constant - caused fatal errors with multisite-clone-duplicator and similar plugins
* FIXED: "headers already sent" warnings from Redirection plugin and other plugins
* IMPROVED: Output buffering prevents header warnings from breaking worker execution
* IMPROVED: Worker loads NewsletterAddon and NewsletterMailerAddon before plugin
* IMPROVED: Worker calls Plugin::instance_init() manually for proper initialization
* IMPROVED: REQUEST_URI now parsed from URL path for correct MultiSite site selection
= 2.2.5 =
* CRITICAL FIX: Worker now loads plugin manually in DOING_CRON context

View file

@ -4,7 +4,7 @@ Tags: newsletter, smtp, email, bulk, queue, worker, amazonses, statistics
Requires at least: 4.7
Tested up to: 6.9
Requires PHP: 7.2
Stable tag: 2.2.5
Stable tag: 2.2.6
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
@ -141,6 +141,18 @@ Yes. The plugin integrates with ROBOTSTXT SMTP rate limiting system to ensure yo
== Changelog ==
= 2.2.6 =
* CRITICAL FIX: Worker now suppresses plugin header warnings in MultiSite environments
* CRITICAL FIX: Fixed Newsletter base class dependencies not loading in DOING_CRON context
* CRITICAL FIX: Worker now manually initializes plugin when newsletter_loaded hook doesn't fire
* CRITICAL FIX: Fixed MultiSite subdirectory site detection - worker now correctly loads site from --url path
* CRITICAL FIX: Removed WP_CLI constant - caused fatal errors with multisite-clone-duplicator and similar plugins
* FIXED: "headers already sent" warnings from Redirection plugin and other plugins
* IMPROVED: Output buffering prevents header warnings from breaking worker execution
* IMPROVED: Worker loads NewsletterAddon and NewsletterMailerAddon before plugin
* IMPROVED: Worker calls Plugin::instance_init() manually for proper initialization
* IMPROVED: REQUEST_URI now parsed from URL path for correct MultiSite site selection
= 2.2.5 =
* CRITICAL FIX: Worker now loads plugin manually in DOING_CRON context
* FIXED: "Newsletter SMTP plugin is not active" error in worker script
@ -196,6 +208,9 @@ Yes. The plugin integrates with ROBOTSTXT SMTP rate limiting system to ensure yo
== Upgrade Notice ==
= 2.2.6 =
CRITICAL: Fixed multiple worker issues in MultiSite environments including header warnings, class loading, and subdirectory site detection. Essential for reliable worker operation.
= 2.2.5 =
CRITICAL: Fixed worker script not loading plugin in DOING_CRON context. Essential for worker functionality.

View file

@ -3,7 +3,7 @@
* Plugin Name: Newsletter - SMTP (by ROBOTSTXT)
* Plugin URI: https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp-newsletter
* Description: Integrates ROBOTSTXT SMTP configuration with Newsletter plugin for efficient bulk email delivery with database-backed queue and external workers.
* Version: 2.2.5
* Version: 2.2.6
* Requires at least: 4.7
* Requires PHP: 7.2
* Security: robotstxt@robotstxt.es
@ -25,7 +25,7 @@ if ( ! defined( 'ABSPATH' ) ) {
}
// Plugin constants.
define( 'ROBOTSTXT_SMTP_NEWSLETTER_VERSION', '2.2.5' );
define( 'ROBOTSTXT_SMTP_NEWSLETTER_VERSION', '2.2.6' );
define( 'ROBOTSTXT_SMTP_NEWSLETTER_FILE', __FILE__ );
define( 'ROBOTSTXT_SMTP_NEWSLETTER_PATH', plugin_dir_path( __FILE__ ) );
define( 'ROBOTSTXT_SMTP_NEWSLETTER_URL', plugin_dir_url( __FILE__ ) );

File diff suppressed because one or more lines are too long

View file

@ -18,6 +18,9 @@
* @since 2.2.0
*/
// Start output buffering to prevent header warnings from plugins.
ob_start();
// Security: CLI-only execution.
if ( php_sapi_name() !== 'cli' ) {
http_response_code( 403 );
@ -56,12 +59,12 @@ if ( $site_url ) {
$_SERVER['HTTPS'] = 'on';
}
// Set REQUEST_URI to root.
$_SERVER['REQUEST_URI'] = '/';
// Set REQUEST_URI from URL path (critical for MultiSite subdirectory detection).
$_SERVER['REQUEST_URI'] = isset( $parsed_url['path'] ) ? $parsed_url['path'] : '/';
}
}
// Load WordPress.
// Load WordPress with CLI context flags.
define( 'DOING_CRON', true );
// Find wp-load.php (3 levels up from plugin directory).
@ -74,11 +77,37 @@ if ( ! file_exists( $wp_load_path ) ) {
require_once $wp_load_path;
// Discard any output from WordPress initialization (headers, plugin warnings, etc.).
ob_end_clean();
// Load Newsletter base classes if not already loaded
if ( ! class_exists( 'NewsletterAddon' ) ) {
$newsletter_base = WP_PLUGIN_DIR . '/newsletter/classes/NewsletterAddon.php';
if ( file_exists( $newsletter_base ) ) {
require_once $newsletter_base;
} else {
fwrite( STDERR, "Error: Newsletter plugin base addon class not found\n" );
exit( 1 );
}
}
if ( ! class_exists( 'NewsletterMailerAddon' ) ) {
$newsletter_mailer = WP_PLUGIN_DIR . '/newsletter/classes/NewsletterMailerAddon.php';
if ( file_exists( $newsletter_mailer ) ) {
require_once $newsletter_mailer;
} else {
fwrite( STDERR, "Error: Newsletter plugin mailer addon class not found\n" );
exit( 1 );
}
}
// Load plugin if not already loaded (happens in DOING_CRON context)
$plugin_manually_loaded = false;
if ( ! defined( 'ROBOTSTXT_SMTP_NEWSLETTER_VERSION' ) ) {
$plugin_file = __DIR__ . '/robotstxt-smtp-newsletter.php';
if ( file_exists( $plugin_file ) ) {
require_once $plugin_file;
$plugin_manually_loaded = true;
} else {
fwrite( STDERR, "Error: Newsletter SMTP plugin file not found\n" );
exit( 1 );
@ -91,6 +120,12 @@ if ( ! defined( 'ROBOTSTXT_SMTP_NEWSLETTER_VERSION' ) ) {
exit( 1 );
}
// If we manually loaded the plugin, we need to initialize it manually
// (normally this happens via newsletter_loaded hook, but that doesn't fire in DOING_CRON)
if ( $plugin_manually_loaded ) {
\Robotstxt_SMTP_Newsletter\Plugin::instance_init();
}
// Get queue and statistics instances.
$queue = \Robotstxt_SMTP_Newsletter\Queue::get_instance();
$stats = \Robotstxt_SMTP_Newsletter\Statistics::get_instance();