I have three lists:

'it' with 2 subscribers
'en' with no subscribers
'nl' with no subscribers

All the lists are with Send rate set to "Custom" and "Custom send rate" set to 1.

When I create a new node for the term tied to the list with subscribers it send the email on a regulary basis of one every two sendings, and at the second submission it does not send the last published node but the first.

Real example:

1. creation of a new node (nid/54) with term "it" selected (the term for the list for which I wanna to trigger the newsletter send)

- table newsletter_newsletter:

| nnid | title | send_id | custom | ntid | subscribers_sent | clicks | opens | last_sent |
| 21 | it | 13 | 0 | 4 | 0 | 0 | 0 | 0 |

- at the same time I puplish the above node in dblog I can find a "notice":
"2 Newsletter Lists failed to send because no subscribers found subscribed to them"

- no newsletter is sent

2. second creation of a new node (nid/55) with term "it" selected

- table newsletter_newsletter, the last inserted row is updated, no new rows are created:

| nnid | title | send_id | custom | ntid | subscribers_sent | clicks | opens | last_sent |
| 21 | it | 13 | 0 | 4 | 2 | 0 | 0 | 1332402956 |

- at the same time I puplish the above node in dblog I can find two "notice":
"2 Newsletter Lists failed to send because no subscribers found subscribed to them"
"2 Newsletter Lists sent"

- a newsletter is sent, but with the node nid/54

and so it go on in an infinite cycle of one not sent and one sent. This behaviour is the same for dev and beta8.

#2 newsletter-customrate1-1493832.patch740 bytestourtools
PASSED: [[SimpleTest]]: [MySQL] 166 pass(es).
[ View ]


ParisLiakos’s picture

Priority:Normal» Major

Seems major to me

tourtools’s picture

Assigned:Unassigned» tourtools
Status:Active» Needs review
new740 bytes
PASSED: [[SimpleTest]]: [MySQL] 166 pass(es).
[ View ]

The function getQuery was checking for nodes created after the last newsletter sent, but if the custom rate is set to 1 the newsletter has to be sent in the same time the node is created. Tested and it works. This time I've attached a git produced patch.

ParisLiakos’s picture

Status:Needs review» Fixed

thanks, commited

Status:Fixed» Closed (fixed)

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

r0bm1lls’s picture

I am still having this problem with the latest dev version. Tried applying the patch - seems it is already applied. ????
Applied patch to beta8 version of newsletter.automated.inc copied that into the dev version - still have problem. The most recent post never sends, only when another node is published does the previous one send when send rate is set to 1

tourtools’s picture

yes, the bug is not solved, it seems that the hook_node_save() is not committing the node to the db as said in the documentation before to call the hook_node_insert, because of this every time the query is executed it return the last but one node inserted and not the last one.
A fairly good explanation and maybe a solution is given in this post.

tourtools’s picture

Status:Closed (fixed)» Needs work

pardon, like I said the bug is not solved

tourtools’s picture

so the only way to send the last node inserted, regardless of every custom rate value, is manage the $node object returned from node_insert() checking if is it or not a node to be sent and aggregate it to the other ones got from the query, it's too hard for me, rootatwc can you manage it? :-)

r0bm1lls’s picture

So the only way for me now is to do manual sends. Pity.

ParisLiakos’s picture

@tourtools thanks for the analysis and explanation, really appreciate it.Will check and fix this once i find some time

tourtools’s picture

Assigned:tourtools» Unassigned

I toggle the assignment from myself, if you can do something is really appreciated :-)

springjazzy’s picture

That happens because table taxonomy_index doesn't contain record for inserted node yet. taxonomy_index rebuilds after newsletter do job on posting. Resolved by adding to newsletter module weight = 100, so that it does all job after all modules.

After applying that patch mails start to send, but there is one problem:

Consider two lists - tagA, tagB with custom send rate = 1.

Add tagA material - sends tagA
Add tagB material - sends tagB and TagA again

That happens because field sent_time in table newsletter_list equals created field in node. So the first time it null -> sends tagA node (equals to tagA created) -> sends tagB node (as it still equals and sql relation for finding proper materials is node.created >= newsletter_list.sent_time it sends again). The problem is in updating table newsletter_list.sent_time to REQUST_TIME that similar to node and newsletter_list. Resolved by addind +1 to REQUEST_TIME.

Hope it helps to publish stable version!

ParisLiakos’s picture

wow, springjazzy very analytical and helpful!
now we just need the patch:)

springjazzy’s picture

I'm noob here, so that patch - should I post it?

ParisLiakos’s picture

ah, np, i will do it

deggertsen’s picture

Did this ever get solved?