Commit Graph

107 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
Mike Jolley
435f638011 Apply rules on lib dir 2024-03-21 16:57:59 +01: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
Rostislav Wolny
6a86dfc7c0 Throw an exception when preprocessing a newsletter without a queue
The goal of this commit is to change the preProcessNewsletter method
to return false only in case when it deleted the newsletter and
all associated entities. So that we know for sure that false means all was deleted.
[MAILPOET-5880]
2024-02-05 15:16:11 +01:00
Jan Jakes
d6da2af55b Extract newsletter bulk delete logic to a controller
Repositories shouldn't inject other repositories. Also, this solves circular DI dependency.

[MAILPOET-5845]
2024-02-02 12:48:40 +01:00
Rodrigo Primo
5646464853 Refactor Mailer::formatSubscriberNameAndEmailAddress() to use Doctrine
[MAILPOET-5758]
2024-01-31 12:44:58 +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
Rodrigo Primo
e7416c247c Fix error after refactor of SendingErrorHandler
In 862c395d3263f30057aef73a14704345e181dde3, SendingErrorHandler was
refactored to replace the `\MailPoet\Tasks\Sending` class with Doctrine
code. Inside `processSoftError()`, a call to
`$sendingTask->saveSubscriberError()` was replaced with a call to
`$this->scheduledTaskSubscribersRepository->saveError()`. The problem is
that the former updates the processed and unprocessed counts in the
QueueEntity while the later doesn't.

This commit fixes this issue by calling
`$this->sendingQueuesRepository->updateCounts()` inside
`processSoftError()`.

[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
c31cbb73c0 Rewrite SendingQueue\Tasks\Links::process() 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
Jan Jakes
b05bc86223 Remove usages of MailPoet\Tasks\Sending from renderer
[MAILPOET-4375]
2023-11-02 12:53:36 +01:00
Rodrigo Primo
2736348feb Remove remaining use of SendingQueue model in Newsletter class
As far as I could test, calling validate() directly is not necessary.
The call to $sendingTask->save() right above calls validate() internaly
and then any errors will be returned by $sendingTask->getErrors().

I added a integration test that seems to confirm this interpretation.

[MAILPOET-4693]
2023-10-30 10:11:11 +01:00
Jan Lysý
998a1ef1f0 Add method for sending recovery from an invalid state
[MAILPOET-4891]
2023-09-14 21:03:08 +02:00
John Oleksowicz
fe44df1884 Prevent invalid states due to filter segment
MAILPOET-5509
2023-08-31 14:16:10 +02:00
John Oleksowicz
bb7a98ad82 Save filter segment data to queue at send time
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
Rodrigo Primo
7c4a84aaf4 Remove notices for hooks that were deprecated over six months ago
[MAILPOET-5272]
2023-04-28 06:05:29 +01: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
9ca259d1d0 Exclude corrupt emails when fetching queue newsletters
[MAILPOET-4983]
2023-03-01 17:46:22 +01:00