diff --git a/changelog.txt b/changelog.txt index 69155e9..1b038ee 100644 --- a/changelog.txt +++ b/changelog.txt @@ -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 diff --git a/readme.txt b/readme.txt index c3398c2..b023cba 100644 --- a/readme.txt +++ b/readme.txt @@ -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. diff --git a/robotstxt-smtp-newsletter.php b/robotstxt-smtp-newsletter.php index fe0e299..055ea44 100644 --- a/robotstxt-smtp-newsletter.php +++ b/robotstxt-smtp-newsletter.php @@ -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__ ) ); diff --git a/update.json b/update.json index f0d393d..4bfb4f5 100644 --- a/update.json +++ b/update.json @@ -1,19 +1,19 @@ { "name": "Newsletter - SMTP (by ROBOTSTXT)", "slug": "robotstxt-smtp-newsletter", - "version": "2.2.5", + "version": "2.2.6", "author": "ROBOTSTXT", "homepage": "https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp-newsletter", - "download_url": "https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp-newsletter/releases/download/2.2.5/robotstxt-smtp-newsletter-2.2.5.zip", + "download_url": "https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp-newsletter/releases/download/2.2.6/robotstxt-smtp-newsletter-2.2.6.zip", "requires": "4.7", "tested": "6.9", "requires_php": "7.2", "last_updated": "2026-02-16", "description": "Integrates ROBOTSTXT SMTP configuration with Newsletter plugin for reliable bulk email delivery with database-backed queue and external workers. Provides persistent email queue, parallel processing, automatic retry, and comprehensive campaign statistics.", - "changelog": "

2.2.5 - 2026-02-16

2.2.4 - 2026-02-16

2.2.3 - 2026-02-16

2.2.2 - 2026-02-16

2.2.1 - 2026-02-16

2.2.0 - 2026-02-16

2.1.0 - 2026-02-09

2.0.1 - 2026-01-29

2.0.0 - 2026-01-29

1.0.0 - 2026-01-29

", + "changelog": "

2.2.6 - 2026-02-16

2.2.5 - 2026-02-16

2.2.4 - 2026-02-16

2.2.3 - 2026-02-16

2.2.2 - 2026-02-16

2.2.1 - 2026-02-16

2.2.0 - 2026-02-16

2.1.0 - 2026-02-09

2.0.1 - 2026-01-29

2.0.0 - 2026-01-29

1.0.0 - 2026-01-29

", "sections": { - "description": "Integrates ROBOTSTXT SMTP configuration with Newsletter plugin for reliable bulk email delivery with database-backed queue and external workers. Version 2.2.5 fixes worker script compatibility ensuring it loads correctly in all WordPress environments. Emails are queued to database and processed by external CLI workers, providing reliability, scalability, and detailed monitoring.", - "changelog": "

2.2.5 - 2026-02-16

2.2.4 - 2026-02-16

2.2.3 - 2026-02-16

2.2.2 - 2026-02-16

2.2.1 - 2026-02-16

2.2.0 - 2026-02-16

" + "description": "Integrates ROBOTSTXT SMTP configuration with Newsletter plugin for reliable bulk email delivery with database-backed queue and external workers. Version 2.2.6 fixes header warnings in MultiSite environments with active plugins like Redirection. Emails are queued to database and processed by external CLI workers, providing reliability, scalability, and detailed monitoring.", + "changelog": "

2.2.6 - 2026-02-16

2.2.5 - 2026-02-16

2.2.4 - 2026-02-16

2.2.3 - 2026-02-16

2.2.2 - 2026-02-16

2.2.1 - 2026-02-16

2.2.0 - 2026-02-16

" }, "banners": { "low": "", diff --git a/worker.php b/worker.php index 9909d2b..52c0e13 100644 --- a/worker.php +++ b/worker.php @@ -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();