Commit Graph

240 Commits

Author SHA1 Message Date
Jan Jakes
b188add536 Fix PHP 8.1 error: Implicit incompatible float to int conversion is deprecated
[MAILPOET-6003]
2024-04-19 09:15:55 +02:00
Mike Jolley
435f638011 Apply rules on lib dir 2024-03-21 16:57:59 +01:00
Pavel Dohnal
a7b67aa23b Ensure the parameter is always int
[MAILPOET-5895]
2024-03-01 14:39:19 +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
8450e1bb1b Clear entity manager for every cron run
This avoids using stale data and prevents memory leaks.

[MAILPOET-5845]
2024-02-02 12:48:40 +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
Jan Jakes
4454dd6203 Delete stats notifications and tasks using a repository
[MAILPOET-5845]
2024-02-02 12:48:40 +01:00
Jan Jakes
9aaffd9ceb Delete newsletter links using a repository
[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
David Remer
836a23c1be Prevent Worker from running when 3rd parties are disabled
[MAILPOET-5826]
2024-01-22 12:11:47 +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
Oluwaseun Olorunsola
639d779088 Unify ProcessedAt timezone
Fix a problem in the codebase where we create, schedule and update newsletters in the user time zone, but we set the ProcessedAt with another timezone

Also, `Carbon::createFromTimestamp($this->wp->currentTime('mysql'))` is not a valid date.
It would return date: '1970-01-01 00:35:29.000000'

MAILPOET-5795
2023-12-25 21:38:02 +01:00
Jan Lysý
525c80bac4 Fix PHPStan warnings in lib
[MAILPOET-5751]
2023-12-13 11:48:14 +01:00
John Oleksowicz
1b31ad11d4 Update UnsubscribeTokens to use DI
MAILPOET-5710
2023-11-13 10:35:54 +01:00
Jan Jakes
c0ef898dc0 Remove no longer needed Scheduler code
[MAILPOET-4375]
2023-11-02 12:53:36 +01:00
Jan Jakes
2d027d4482 Rewrite Scheduler::processScheduledTransactionalEmail() using Doctrine
[MAILPOET-4375]
2023-11-02 12:53:36 +01:00
Jan Jakes
a8a98478fe Rewrite Scheduler::processScheduledAutomationEmail() using Doctrine
[MAILPOET-4375]
2023-11-02 12:53:36 +01:00
Jan Jakes
bd193968b1 Rewrite Scheduler::processReEngagementEmail() using Doctrine
[MAILPOET-4375]
2023-11-02 12:53:36 +01:00
Jan Jakes
a488d0b275 Rewrite Scheduler::processScheduledAutomaticEmail() using Doctrine
[MAILPOET-4375]
2023-11-02 12:53:36 +01:00
Jan Jakes
d574b55b3f Rewrite Scheduler::processScheduledStandardNewsletter() using Doctrine
[MAILPOET-4375]
2023-11-02 12:53:36 +01:00
Jan Jakes
1ef88a5fb5 Rewrite Scheduler::processPostNotificationNewsletter() using Doctrine
[MAILPOET-4375]
2023-11-02 12:53:36 +01:00
Jan Jakes
6517c697d6 Rewrite Scheduler::processWelcomeNewsletter() using Doctrine
[MAILPOET-4375]
2023-11-02 12:53:36 +01:00
Jan Jakes
a1c0399e96 Implement scheduler task, queue, and subscribers removal with Doctrine
[MAILPOET-4375]
2023-11-02 12:53:36 +01:00
Jan Jakes
e81a7c1517 Enable usage of both Doctrine and legacy task/queue entities in scheduler loop
[MAILPOET-4375]
2023-11-02 12:53:36 +01:00
Jan Jakes
b05bc86223 Remove usages of MailPoet\Tasks\Sending from renderer
[MAILPOET-4375]
2023-11-02 12:53:36 +01:00
Jan Jakes
728e1781c6 Remove usages of MailPoet\Tasks\Sending from stats notification worker
[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
Rodrigo Primo
4d3ee84e38 Improve query by getting only the ID as we don't need the rest
[MAILPOET-5680]
2023-10-30 09:56:38 +01:00
Rodrigo Primo
f2214c8cf9 Refactor UnsubscribeTokens to use Doctrine instead of Paris
[MAILPOET-5680]
2023-10-30 09:56:38 +01:00