I set up a followup to send immediately as the order is placed and while it is in "Pending" status (for bank transfer orders) which reminds the user of how to pay. It's supposed to repeat once every 24 hours, for as long as the order remains in "Pending". I also have the settings set to send 100 per cron run.
What has happened instead is that, every 5 minutes (when cron is run), emails go out. My clients are furious with me. It would seem that the followup module isn't keeping track of the time the last email was sent or something similar. This is pretty dangerous!
I haven't had a look at the code (no time for now) but will in the future if no one else can. It will just have to be a few weeks from now as I'm really overloaded.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | uc_followup-query-logic.patch | 1.32 KB | webchick |
Comments
Comment #1
webchickI'm seeing this as well, though luckily on my dev server using Devel module as the mail gateway, so we're not actively ticking anyone off, yet. ;)
I would've expected that the module would only send off mails for *new* orders since turning it on, but it seems to do them for all of them, each time cron runs.
Comment #2
webchickIn uc_followup_cron(), there is a query aptly named $mega_query:
The issue is in the where clause:
For most orders, o.modified will be a date long in the past. Therefore, it's always going to be less than the current date, and the code will fire for every order assigned to the proper status. :\
This should be switched to BETWEEN logic, ranging from the current time to X hours previous.
Comment #3
webchickI think this will work. Though note that I didn't test the branch utilizing repeat_after, which I think was the original poster's issue. I also put in a minor performance enhancement of only calculating time() once.
With this patch applied, the query returns 3 records for me rather than 231 on the first run. Then on the second run, it returns 0 records, since these records now exist in the uc_followup_sent table.
Comment #4
neochief commentedCommited. Thanks for figuring this out.
Comment #5
webchickOh, awesome! Thanks for the speedy commits, neochief! :)
Comment #6
neochief commentedI'm super-fast if someone provides patches (rare thing). Thanks anyways :)
Comment #7
norio commentedSorry for disappearing :) Will try out the patch sometime in the new year. (I resorted to a manual module in the meanwhile after people wanted to hack my head off for spamming them :D)
Comment #9
m.stentaI think that the BETWEEN date logic here is flawed. I made a full review of the $mega_query, to get a better understanding of what it's doing. It is the third comment in this issue: #1477036: Reworking uc_followup_cron() and the $mega_query
I came up with a better possible solution to the issue of past orders sending out unwanted followups, which seems to be the real problem in THIS issue. See my other comment on the thread mentioned above here: http://drupal.org/node/1477036#comment-5751218