Commit Graph

117 Commits

Author SHA1 Message Date
Rostislav Wolny
ff5a41a8ee Update outdated comment about recurring action in Daemon Run action
[MAILPOET-4684]
2022-10-13 14:21:43 +02:00
Rostislav Wolny
69ac29d0a7 Allow immediate processing of just prepared tasks in cron worker runner
Preparing simple worker tasks is super fast, because it just switches the state to null.
But the processing of just prepared tasks required the second worker run and also second cron run.
This change optimize the behavior and in case there is still time left it immediately starts processing the tasks.
[MAILPOET-4684]
2022-10-13 14:21:43 +02:00
Rostislav Wolny
05b441378d Add logging of suspiciously terminated cron runs
[MAILPOET-4684]
2022-10-13 14:21:43 +02:00
Rostislav Wolny
9c0ce5ed7a Refactor DaemonRun::afterProcess for better readability
[MAILPOET-4684]
2022-10-13 14:21:43 +02:00
Rostislav Wolny
de22257af3 Do not schedule next action scheduler run after suspiciously short run
In case we still have work to do but the previous run ended too early and it still had some execution time left
we will not schedule new action.
This is prevention for creating a run action every one second in case there is e.g. some stuck job.
Next run will be triggered within the trigger action that runs every 2 minutes.
[MAILPOET-4684]
2022-10-13 14:21:43 +02:00
Rostislav Wolny
a03f8f1c30 Use action scheduler's unique single action for daemon run
With the new unique parameter added in the action scheduler 3.5.0 the
as_schedule_single_action that schedules an immediate action
seems to be more convenient for the action scheduler.
We get better control over the scheduling of subsequent runs.
Note: We don't want to use the async action that is also executed immediately,
but it has the highest priority and we don't want to block actions scheduled by other plugins.
[MAILPOET-4684]
2022-10-13 14:21:43 +02:00
Rostislav Wolny
e33539c5ca Prevent triggering cron when sending is waiting for retry
[MAILPOET-4686]
2022-10-13 14:21:43 +02:00
Rostislav Wolny
1711d60871 Schedule recurring actions as unique to prevent duplicate actions
We had some cases of multiple triggers created most probably because of a race conditions.
The unique action functionality added in the action scheduled 3.5.0 should prevent it.
[MAILPOET-4684]
2022-10-13 14:21:43 +02:00
Rostislav Wolny
4d7f6f8c75 Use more effective method deactivation
This will cancel all jobs with one query. Instead of cancelling one by one.
In case that some action gets scheduled multiple times e.g. due a race condition
it will remove all jobs.
2022-10-13 14:21:43 +02:00
David Remer
522629eeff Update other instances where SendingTask and Entity get out of sync
[MAILPOET-4708]
2022-10-10 17:13:17 +02: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
94da004454 Refresh newsletterEntity and taskEntity.
We need to refresh those, because the database values have
changed and Doctrine needs to clear its internal cache.

[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
David Remer
1a8f0c384c Improve logging of errors in cron
Sometimes errors overlap each other so that the 'Last Seen error' we log
does not provide sufficient information on the cause of a problem.

E.g. one worker might cause an SQL issue, which closes the EntityManager and a
subsequent worker might overwrite this error with the information that the
EntityManager is closed.

With this commit, both those issues will be logged as an error.

[MAILPOET-4699]
2022-10-06 12:06:13 +02:00
Rodrigo Primo
54ea394f82 Deprecate filter as part of a Doctrine refactor
This commit deprecates the filter
mailpoet_sending_newsletter_render_after and replaces it with
mailpoet_sending_newsletter_render_after_pre_process. This was necessary
because as part of a Doctrine refactor one of the parameters passed to
the old filter changed from a Newsletter model to a Newsletter entity.

[MAILPOET-4680]
2022-10-04 14:41:00 +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
Rodrigo Primo
095cddc67e Change Posts::getAlcPostsCount() to use Doctine instead of Paris
[MAILPOET-4680]
2022-10-04 14:41:00 +02:00
Rodrigo Primo
83319949ef Use WooCommerce code instead of direct query to get highest order ID
[MAILPOET-4570]
2022-10-03 09:30:42 +02:00
Jan Lysý
58d32a68fb Use processedAt from the correct model
[MAILPOET-4685]
2022-09-29 15:19:09 -03:00
Jan Lysý
0551d02815 Add refreshing sending queue
Because we are still working with old model on some places, it's necessary to refresh both sides of the relation.
[MAILPOET-4685]
2022-09-29 15:19:09 -03:00
Jan Lysý
2cf3f37f5c Fix creation notification history records
[MAILPOET-4679]
2022-09-26 13:23:28 +02:00
Rostislav Wolny
45257b7b99 Simplify subscribers last engagement migration by ignoring Woo data
[MAILPOET-4578]
2022-09-26 10:20:32 +02:00
Rodrigo Primo
2c159b1694 Document the types of two SendingQueue properties that were undocumented
It was also necessary to add an if condition to check the type of a
variable before calling one of the methods of one of the documented
properties.

[MAILPOET-4363]
2022-09-21 16:03:21 +02:00
Rodrigo Primo
f578f3f16a Remove method Tasks\Newsletter\getNewsletterSegments()
This method was used only once inside SendingQueue and it can be
replaced by NewsletterEntity::getSegmentIds() to simplify the code.

[MAILPOET-4363]
2022-09-21 16:03:21 +02:00
Rodrigo Primo
d79cecbef2 Replace some of the uses of SendingQueue model with Doctrine
[MAILPOET-4363]
2022-09-21 16:03:21 +02:00
Rodrigo Primo
ccbdbd3e93 Refactor getNewsletterFromQueue() to use Doctrine instead of Paris
[MAILPOET-4363]
2022-09-21 16:03:21 +02:00
Rodrigo Primo
4ca656a217 Rename $queue to $sendingTask
Doing this for consistency and to make it more clear that $sendingTask
contains an instance of \MailPoet\Tasks\Sending and not an instance of
\MailPoet\Models\SendingQueue.

[MAILPOET-4363]
2022-09-21 16:03:21 +02:00
Rodrigo Primo
a7d0ad6568 Set the type of all the Newsletter parameters that use the Sending class
[MAILPOET-4363]
2022-09-21 16:03:21 +02:00
Rodrigo Primo
168ce20a40 Use NewsletterEntity instead of Newsletter model in Links
[MAILPOET-4363]
2022-09-21 16:03:21 +02:00
Rodrigo Primo
9a92068d5b Refactor Newsletter to use Doctrine instead of the Newsletter model
[MAILPOET-4363]
2022-09-21 16:03:21 +02:00
Rodrigo Primo
f6afe987c8 Add return type declaration for Newsletter::prepareNewsletterForSending()
[MAILPOET-4363]
2022-09-21 16:03:21 +02:00
Rodrigo Primo
68c3277195 Replace Subscriber model with Doctrine in Tasks\Newsletter
[MAILPOET-4363]
2022-09-21 16:03:21 +02:00
Rodrigo Primo
fd0acbd6cf Refactor Newsletter to use Doctrine instead of the NewsletterSegment model
[MAILPOET-4363]
2022-09-21 16:03:21 +02:00
Rodrigo Primo
05664a0c6a Refactor markNewsletterAsSent() to use Doctrine instead of Paris
[MAILPOET-4363]
2022-09-21 16:03:21 +02:00
Jan Lysý
bc8be524fb Use ScheduledTaskEntity instead of Sending
[MAILPOET-4367]
2022-09-19 11:07:16 +02:00
Jan Lysý
97801cfe25 Remove usage of Sending::getScheduledQueues
[MAILPOET-4367]
2022-09-19 11:07:16 +02:00
Rodrigo Primo
538647946e Refactor GATracking to use Doctrine instead of Paris
The test class was also refactored.

[MAILPOET-4592]
2022-09-14 10:38:01 +02:00
Jan Jakes
047bd94d98 Implement sending for automation emails
[PREMIUM-194]
2022-09-08 09:20:20 +02:00
Jan Lysý
f9261dbeb4 Use constants from ScheduledTaskEntity
[MAILPOET-4309]
2022-08-31 13:42:21 +02:00
Jan Lysý
fecb26b3b5 Replace usage ScheduledTask::touchAllByIds with repository
[MAILPOET-4309]
2022-08-31 13:42:21 +02:00
Jan Lysý
c1e9f86a32 Remove usage of old model for creating post notification history
[MAILPOET-4310]
2022-08-22 11:04:45 +02:00
Jan Lysý
5dfda9f3e2 Move task type const from entity to worker
[MAILPOET-4366]
2022-08-19 15:11:23 +02:00
Jan Lysý
bf74a506b7 Replace using Sending::getRunningQueues
[MAILPOET-4366]
2022-08-19 15:11:23 +02:00
David Remer
97e160bf67 Fix WordPress.WP.I18n.MissingArgDomain
[MAILPOET-4524]
2022-08-09 13:23:16 +02:00
David Remer
218de96024 Fix WordPress.WP.I18n.MissingTranslatorsComment errors
[MAILPOET-4524]
2022-08-09 13:23:16 +02:00
David Remer
b05e6d414c Remove WP\Functions::__ and other translate functions
Under the new sniffer rules, those functions produce errors and, when those methods
are used, the sniffer can not properly be applied.

[MAILPOET-4524]
2022-08-09 13:23:16 +02:00
Rodrigo Primo
73f51523f3 Replace Paris models with Doctrine entities in SubscriberLinkTokens
[MAILPOET-4345]
2022-08-04 11:52:57 +02:00
Rodrigo Primo
af396021db Move the query to calculate the max subscriber ID to SubscribersRepository
[MAILPOET-4344]
2022-08-04 11:10:50 +02:00
Rodrigo Primo
8a29519b31 Replace Paris models with Doctrine entities in InactiveSubscribers
[MAILPOET-4344]
2022-08-04 11:10:50 +02:00
Rodrigo Primo
261f2eaa25 Replace Paris models with Doctrine entities in Shortcodes
[MAILPOET-4364]
2022-08-04 10:55:03 +02:00