Commit Graph

73 Commits

Author SHA1 Message Date
Rostislav Wolny
33f4b2d729 Replace usage of WP's current_time without gmt parameter in libs
This commit replaces usages by Carbon::now or in case we need a timestamp it
keeps current_time but adds the gtm parameter as true.
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
David Remer
fd0d1036e6 Add isTransactional method to NewsletterEntity
[MAILPOET-6115]
2024-07-01 13:01:30 +02:00
Rostislav Wolny
a7df6b496f Add logging for unexpected states when we reach the end of sending
[MAILPOET-5881]
2024-06-07 11:32:46 +02:00
Rostislav Wolny
9dd808a070 Set as invalid only for non-campaign email types
For non-campaign emails, we use scheduled tasks to display processed stats.
The invalid tasks are no longer processed, and they don't block the queue
and are not counted in the stats.
For campaign emails (bulk emails), we just mark them as sent to zero recipients.
[MAILPOET-5881]
2024-06-07 11:32:46 +02:00
Rostislav Wolny
e4cff6c14f Remove an unnecessary condition in the batch processing loop
The batch will be continued anyway because of the next condition
if (!$queue->getCountToProcess()) {
  continue;
}
The newsletter entity will be marked as sent (plus other stuff related to finished sending)
after the loop in $this->endSending.
2024-06-07 11:32:46 +02:00
Rostislav Wolny
55ae6264cc Add method for processing end of sending for completed tasks
[MAILPOET-5881]
2024-06-07 11:32:46 +02:00
Rostislav Wolny
1111bac58b Unify behavior for sending paused during processing
In all other cases when we pause sending, we immediately end
the processSending method. In this case, we would unnecessarily
start processing one more batch.
[MAILPOET-5881]
2024-06-07 11:32:46 +02:00
Jan Jakes
4c1b2e46c8 Trigger automation email sent hook for automation emails
[MAILPOET-4977]
2024-05-06 12:39:00 +02:00
Rostislav Wolny
749c4e5e43 Prevent deleting and further changes in detached tasks during sending
When a post notification history is deleted in
MailPoet\Cron\Workers\SendingQueue\Tasks\Newsletter::preProcessNewsletter
it is also detached from EntityManager.

Any further attempt to manipulate the entity via EntityManager (remove or flush) causes
errors like "ERROR: A new entity was found through the relationship 'MailPoet\Entities\ScheduledTaskEntity#sendingQueue'"

In this commit we prevent doing such changes.
[MAILPOET-5880]
2024-02-05 15:16:11 +01:00
Brezo Cordero
dffebc231e Add comment on check for PAUSED task during batch processing
[MAILPOET-5832]
2024-01-20 13:39:23 +05:00
Brezo Cordero
e7aa261828 Process Soft error for domain authorization
Pause the task and do not update counts.

[MAILPOET-5832]
2024-01-20 13:39:23 +05:00
Brezo Cordero
42618ab15c Pause sending task if sender address not valid
[MAILPOET-5832]
2024-01-20 13:39:23 +05:00
Jan Jakes
dbd88f8313 Simplify fetching subscriber IDs
[MAILPOET-5737]
2024-01-17 22:32:37 +05:00
Rodrigo Primo
33769e703c Replace StatisticsNewsletters model with Doctrine in SendingQueue
[MAILPOET-5737]
2024-01-17 22:32:37 +05:00
Rodrigo Primo
4fe642916e Replace Newsletter model with Doctrine in SendingQueue
[MAILPOET-5737]
2024-01-17 22:32:37 +05:00
Rodrigo Primo
83826b3f65 Replace Subscriber model with Doctrine in SendingQueue and SendingQueueTest
[MAILPOET-5737]
2024-01-17 22:32:37 +05:00
Rodrigo Primo
e96251db7e Fix bug when changing ScheduledTask in_progress field
In 3394568, SendingQueue::stopProgress() was refactored to use Doctrine
but a typo introduced a bug causing this method to set
ScheduledTaskEntity::inProgress to true instead of false:

3394568792 (diff-3a26b2d8faf9cc01efd5aef47b058c088c0de01b8074c3be7cefd9adb77fbaaaR551)

This luckly was caught by the
EditorCouponCest.php:seeNoticeWhenCouponCantGenerateAndResumeSending
acceptance test.

This commit fixes the problem and also adds two integration tests to
protect against similar regressions in the future.

[MAILPOET-5682]
2024-01-12 13:25:46 +01:00
Jan Jakes
e3ff7ccaca Remove remaining usages of MailPoet\Task\Sending from SendingQueue::processSending()
[MAILPOET-5682]
2024-01-12 13:25:46 +01:00
Jan Jakes
fa266dadcd Rewrite SendingErrorHandler using Doctrine
[MAILPOET-5682]
2024-01-12 13:25:46 +01:00
Jan Jakes
7e45fb1c79 Rewrite SendingQueue::sendNewsletter(), sendNewsletters(), and processSendResult() using Doctrine
[MAILPOET-5682]
2024-01-12 13:25:46 +01:00
Jan Jakes
586ef334b0 Rewrite SendingQueue\Tasks\Newsletter::prepareNewsletterForSending() using Doctrine
[MAILPOET-5682]
2024-01-12 13:25:46 +01:00
Jan Jakes
44c5ae5664 Pass Doctrine entity into SendingQueue::processQueue(), replace simple usages
[MAILPOET-5682]
2024-01-12 13:25:46 +01:00
Jan Jakes
ec792b30df Rewrite SendingQueue\Tasks\Newsletter::preProcessNewsletter() using Doctrine
[MAILPOET-5682]
2024-01-12 13:25:46 +01:00
Jan Jakes
16b2817ce6 Rewrite SendingQueue\Tasks\Newsletter::getNewsletterFromQueue() using Doctrine
[MAILPOET-5682]
2024-01-12 13:25:46 +01:00
Jan Jakes
737c80f953 Rewrite SendingQueue::deleteTaskIfNewsletterDoesNotExist() and deleteTask() using Doctrine
[MAILPOET-5682]
2024-01-12 13:25:46 +01:00
Jan Jakes
ff9b2a1adb Pass Doctrine entity into SendingQueue::processSending(), replace simple usages
[MAILPOET-5682]
2024-01-12 13:25:46 +01:00
Jan Jakes
6307f6c155 Rewrite SendingQueue::process() and progress/timeout functions using Doctrine
[MAILPOET-5682]
2024-01-12 13:25:46 +01:00
Oluwaseun Olorunsola
c76c8f2abb Save the correct datetime value for newsletter sentAt column
We don't need to use the value from `processedAt` here since we can rightfully use the current datetime value

Also, I found out `processedAt` is usually null here for standard newsletters which cause new Carbon to use the server datetime settings

MAILPOET-5795
2023-12-25 21:38:02 +01:00
John Oleksowicz
fe44df1884 Prevent invalid states due to filter segment
MAILPOET-5509
2023-08-31 14:16:10 +02:00
John Oleksowicz
3745b17465 Filter subscribers during sending if filterSegment present
MAILPOET-5509
2023-08-31 14:16:10 +02:00
John Oleksowicz
9b8c4910c1 If newsletter has filterSegmentId, pause if it doesn't exist
MAILPOET-5509
2023-08-31 14:16:10 +02:00
John Oleksowicz
021d8774e7 Wrap bulk updates in a transaction
MAILPOET-5410
2023-08-11 16:39:57 +02:00
John Oleksowicz
f8e0ba118c Nullify engagement score updated at after sends
This will cause the cron job that recalculates engagement score to pick
up these users the next time it runs. This ensures scores don't get
stale.

MAILPOET-5410
2023-08-11 16:39:57 +02:00
John Oleksowicz
b22217420f Track last sending at
MAILPOET-4998
2023-06-22 15:29:22 +02:00
Rodrigo Primo
75f8af13be Refactor MetaInfo::getNewsletterMetaInfo() to use Doctrine
[MAILPOET-5344]
2023-05-25 06:52:00 -05:00
Jan Jakes
69f21814e3 Rename "transactional" email type to "automation_transactional"
[MAILPOET-5258]
2023-04-24 09:54:08 +03:00
David Remer
0ce8fce161 Send transactional emails to all not-bounced subscribers
[MAILPOET-4999]
2023-04-17 13:59:39 +02:00
Sam Najian
397232e932 Set status of scheduled_task to invalid if it has not subs
[MAILPOET-5134]
2023-04-03 11:53:49 +02:00
Sam Najian
fdf0875905 Pause sending queue when encountering a corrupt newsletter
[MAILPOET-4983]
2023-03-01 17:46:22 +01:00
Sam Najian
93110826e7 Log when processing the queue for corrupt newsletter
[MAILPOET-4983]
2023-03-01 17:46:22 +01:00
John Oleksowicz
49c85c05ed Move campaignId generation to more logical place
MAILPOET-5034
2023-02-26 15:20:48 +01:00
John Oleksowicz
a6824cce36 Add tests for campaignId generation
[MAILPOET-5033]
2023-02-26 15:20:48 +01:00
John Oleksowicz
fc8436ba74 Provide campaignId to sending methods via meta
[MAILPOET-5033]
2023-02-26 15:20:48 +01:00
John Oleksowicz
0435c09c53 Calculate and store campaign IDs on sending queues
[MAILPOET-5033]
2023-02-26 15:20:48 +01:00
Jan Jakes
926620e8f8 Ignore strict types rule in all existing files that don't have it
[MAILPOET-2688]
2022-11-29 15:04:09 +01:00
David Remer
2557171953 Fix assert() in lib
[MAILPOET-4258]
2022-11-25 14:32:34 +01:00
Sam Najian
50b613365f Make sure one-click unsubscribe url won't redirect internally
[MAILPOET-4703]
2022-11-11 09:21:30 +01:00
David Remer
2298b5b061 Be more restrictive when deleting a queue task
getNewsletterFromQueue() has too many conditions under which it returns null. Therefore we can not rely on that method when we wont to delete running tasks with no associated newsletter.
[MAILPOET-4708]
2022-10-10 17:13:17 +02:00
David Remer
307989a0c6 Delete task when no newsletter was found
When no corresponding newsletter was found the task can be deleted. The behavior
before meant that such a task would remain forever in the database with the
status 'running'.

[MAILPOET-4699]
2022-10-06 12:06:13 +02:00
Rodrigo Primo
d39440f1dc Refactor Newsletter::preProcessNewsletter() to use Doctrine
This commit also removes almost all the usages of the old Newsletter
model from NewsletterTest.

[MAILPOET-4680]
2022-10-04 14:41:00 +02:00