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]
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]
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]
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]
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.
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]
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]
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]
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]
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]
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]