v2.2.4
This commit is contained in:
parent
ed2cc2f70a
commit
97ed06ef72
5 changed files with 42 additions and 15 deletions
|
|
@ -195,13 +195,24 @@ class Plugin extends \NewsletterMailerAddon {
|
|||
$speed = $this->calculate_optimal_speed( $smtp_settings );
|
||||
|
||||
// CRITICAL: For queue-based architecture, speed must be high enough
|
||||
// that Newsletter loads all emails at once. Newsletter calculates
|
||||
// batch_size = speed / (60 / cron_interval). With default 5-minute cron:
|
||||
// batch_size = speed / 12. To get batch_size = configured value,
|
||||
// we need: speed = batch_size * 12.
|
||||
$batch_size = $settings['batch_size'] ?? 10;
|
||||
$speed_multiplier = 12; // Assumes 5-minute cron (12 executions per hour).
|
||||
$calculated_speed = max( $speed, $batch_size * $speed_multiplier );
|
||||
// that Newsletter loads all emails at once. Newsletter calculates:
|
||||
// batch_size = speed / (3600 / NEWSLETTER_CRON_INTERVAL)
|
||||
// To get batch_size = configured value, we need:
|
||||
// speed = batch_size * (3600 / NEWSLETTER_CRON_INTERVAL)
|
||||
$batch_size = $settings['batch_size'] ?? 10;
|
||||
|
||||
// Ensure NEWSLETTER_CRON_INTERVAL is loaded
|
||||
if ( ! defined( 'NEWSLETTER_CRON_INTERVAL' ) ) {
|
||||
$cron_file = WP_PLUGIN_DIR . '/newsletter/includes/cron.php';
|
||||
if ( file_exists( $cron_file ) ) {
|
||||
require_once $cron_file;
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate runs per hour based on Newsletter's cron interval
|
||||
$cron_interval = defined( 'NEWSLETTER_CRON_INTERVAL' ) ? NEWSLETTER_CRON_INTERVAL : 300;
|
||||
$runs_per_hour = (int) ( 3600 / $cron_interval );
|
||||
$calculated_speed = max( $speed, $batch_size * $runs_per_hour );
|
||||
|
||||
// Newsletter expects 'turbo' for batch_size and 'speed' for emails/hour.
|
||||
$mailer_options = array(
|
||||
|
|
|
|||
Loading…
Reference in a new issue