Compare commits

...

4 Commits

Author SHA1 Message Date
18e2d26587 Bump up release version to 3.0.0-beta.23.2 2017-03-15 14:35:44 +02:00
810a7bf544 Merge pull request #848 from mailpoet/welcome_emails_fix
Fix Welcome email sending [MAILPOET-859]
2017-03-15 13:59:57 +02:00
1010c6f4f0 Remove a space [MAILPOET-859] 2017-03-15 13:15:34 +03:00
8dd698ec75 Fix Welcome email sending [MAILPOET-859] 2017-03-15 12:12:47 +03:00
4 changed files with 65 additions and 8 deletions

View File

@ -43,10 +43,19 @@ class SendingQueue {
self::BATCH_SIZE
);
foreach($subscriber_batches as $subscribers_to_process_ids) {
$found_subscribers = SubscriberModel::findSubscribersInSegments(
$subscribers_to_process_ids, $newsletter_segments_ids
)->findMany();
$found_subscribers_ids = SubscriberModel::extractSubscribersIds($found_subscribers);
if(!empty($newsletter_segments_ids[0])) {
// Check that subscribers are in segments
$found_subscribers = SubscriberModel::findSubscribersInSegments(
$subscribers_to_process_ids, $newsletter_segments_ids
)->findMany();
$found_subscribers_ids = SubscriberModel::extractSubscribersIds($found_subscribers);
} else {
// No segments = Welcome emails
$found_subscribers = SubscriberModel::whereIn('id', $subscribers_to_process_ids)
->whereNull('deleted_at')
->findMany();
$found_subscribers_ids = SubscriberModel::extractSubscribersIds($found_subscribers);
}
// if some subscribers weren't found, remove them from the processing list
if(count($found_subscribers_ids) !== count($subscribers_to_process_ids)) {
$subscibers_to_remove = array_diff(

View File

@ -4,7 +4,7 @@ if(!defined('ABSPATH')) exit;
/*
* Plugin Name: MailPoet
* Version: 3.0.0-beta.23.1
* Version: 3.0.0-beta.23.2
* Plugin URI: http://www.mailpoet.com
* Description: Create and send beautiful email newsletters, autoresponders, and post notifications without leaving WordPress. This is a beta version of our brand new plugin!
* Author: MailPoet
@ -21,7 +21,7 @@ if(!defined('ABSPATH')) exit;
*/
$mailpoet_plugin = array(
'version' => '3.0.0-beta.23.1',
'version' => '3.0.0-beta.23.2',
'filename' => __FILE__,
'path' => dirname(__FILE__),
'autoloader' => dirname(__FILE__) . '/vendor/autoload.php',

View File

@ -3,7 +3,7 @@ Contributors: mailpoet, wysija
Tags: newsletter, email, welcome email, post notification, autoresponder, signup, smtp
Requires at least: 4.6
Tested up to: 4.7.3
Stable tag: 3.0.0-beta.23.1
Stable tag: 3.0.0-beta.23.2
Create and send beautiful emails and newsletters from WordPress.
== Description ==
@ -84,7 +84,7 @@ Our [support site](https://docs.mailpoet.com/) has plenty of articles. You can w
== Changelog ==
= 3.0.0-beta.23.1 - 2017-03-14 =
= 3.0.0-beta.23.2 - 2017-03-14 =
* Improved: added plugin translations to Dutch, English (UK), French, German, Italian, Portuguese (Brazil), Portuguese (Portugal), Russian and Spanish languages. Thank you translators!
* Fixed: unsubscribed subscriber will no longer receive newsletters (woops!). Thanks, Oskar;
* Fixed: previously scheduled send tasks are rescheduled when post notifications' scheduling options change. Thanks, Karen and Eric!

View File

@ -282,6 +282,54 @@ class SendingQueueTest extends MailPoetTest {
expect($statistics)->notEquals(false);
}
function testItCanProcessWelcomeNewsletters() {
$this->newsletter->type = Newsletter::TYPE_WELCOME;
$this->newsletter_segment->delete();
$sending_queue_worker = new SendingQueueWorker(
$timer = false,
Stub::make(
new MailerTask(),
array(
'send' => Stub::exactly(1, function($newsletter, $subscriber) {
// newsletter body should not be empty
expect(!empty($newsletter['body']['html']))->true();
expect(!empty($newsletter['body']['text']))->true();
return true;
})
)
)
);
$sending_queue_worker->process();
// newsletter status is set to sent
$updated_newsletter = Newsletter::findOne($this->newsletter->id);
expect($updated_newsletter->status)->equals(Newsletter::STATUS_SENT);
// queue status is set to completed
$updated_queue = SendingQueue::findOne($this->queue->id);
expect($updated_queue->status)->equals(SendingQueue::STATUS_COMPLETED);
// queue subscriber processed/to process count is updated
$updated_queue->subscribers = $updated_queue->getSubscribers();
expect($updated_queue->subscribers)->equals(
array(
'to_process' => array(),
'processed' => array($this->subscriber->id)
)
);
expect($updated_queue->count_total)->equals(1);
expect($updated_queue->count_processed)->equals(1);
expect($updated_queue->count_to_process)->equals(0);
// statistics entry should be created
$statistics = StatisticsNewsletters::where('newsletter_id', $this->newsletter->id)
->where('subscriber_id', $this->subscriber->id)
->where('queue_id', $this->queue->id)
->findOne();
expect($statistics)->notEquals(false);
}
function testItRemovesNonexistentSubscribersFromProcessingList() {
$queue = $this->queue;
$queue->subscribers = serialize(