Currently when cron runs and an edition is made, it then sits as waiting to be sent until the next cron run.

(This issue split off from #1461944: Cleanup and use simplenews api functions in _simplenews_scheduler_new_edition().)

On D6 we need to use module weights, but on D7 we can use http://api.drupal.org/api/drupal/modules!system!system.api.php/function/...

CommentFileSizeAuthor
#3 add_module_weight.patch1.83 KBBerdir
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim’s picture

Title: run our cron before Simplenews » newsletters take 2 cron runs to send: run our cron before Simplenews?

I'm actually instinctively feeling icky about a dependent module being weighted to run before its dependency -- won't that have all sorts of knock-on effects including form_alter hooks?

I'm retitling this issue accordingly. Would it be possible to call simplenews's 'send newsletters' API function (whatever it is) at the end of our hook_cron()?

Berdir’s picture

No, we shouldn't do that. We actually don't even use simplenews_cron() here for example (we have disabled it using elysia cron) but instead have a simple script to get the newsletter out as fast as possible.

We're altering a form that is created by Simplenews, not after Simplenews altered it, so the module weight doesn't have any effect.

Berdir’s picture

Status: Active » Needs review
FileSize
1.83 KB

Re-adding the parts from the initial patch with updated update function number.

This is IMHO a perfectly fine thing to do. This works fine out of the box and you can always change the weight if you have specific requirements. We also don't touch sites which already have customized the weight.

I'm not sure if elysia cron relies on module weight and/or hook implementation order. I tried to have a look but they one of those projects who try to support both D6 and D7 with millions of conditions and versions checks and almost no documentation at the same time. Stopped bothering :p

joachim’s picture

I have been wondering whether this is a feature rather than a bug...

Last month, when my site's cron run created the newsletter node, I had time to check it and fix a couple of errors on the content before it was sent by the next cron run :)

miro_dietiker’s picture

Status: Needs review » Needs work

Looks good to me, Berdir, but i think we should apply the condition for type=module in order to avoid other possibly wrong updates.
(Although there don't seem to be other different lines...)

dgtlmoon’s picture

Status: Needs work » Reviewed & tested by the community

Looks fine to me

dgtlmoon’s picture

Status: Reviewed & tested by the community » Fixed

comitted

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.