Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When I'm calling message_subscribe_send_message() with set parameters of:
$subscribe_options['use queue'] = TRUE;
$subscribe_options['uids'] = $subscribers;
Than queue enters into a loop.
Comment | File | Size | Author |
---|---|---|---|
#12 | prevent_loop_of_message-2303795-12.patch | 910 bytes | klaasvw |
| |||
#11 | prevent_loop_of_message-2303795-11.patch | 605 bytes | tripper54 |
#1 | no_que_and_uid_loop.patch | 463 bytes | bsandor |
Comments
Comment #1
bsandor CreditAttribution: bsandor commentedMy Understanding is that $subscribe_options['queue'] is for deciding if we are calling message_subscribe_send_message() from the queue worker.
If that is the case than this code goes into a loop as it is called from XXXX and even when it's calles from there it contains XXX so it will add another line into {queue}.
So my idea is that this part needs another condition for testing if $subscribe_options['queue'] is set. So first line should be:
I'm attaching a patch that solved this issue for me.
I used this pathch with this one: https://www.drupal.org/files/issues/dupenotifications-2299083-1_0.patch
Comment #2
dmsmidtThere are two occurrences in the code in which a queue task is added.
The first time a check for $subscribe_options['queue'] is already implemented.
But the second time it isn't. Additionally, for me, it is not clear at all why this task adding code block is there the second time at all.
I guess this second block of code can be safely removed.
Or was the plan to have a fallback for when the task times out?
But then still some logic is missing.
Comment #3
tanius CreditAttribution: tanius commentedI can confirm that the two patches referred in #1 fixed the issue for me.
Context, also for others searching for the cause to their problem: We experienced this issue when sending messages to specific uids in queue mode, using a custom module which used the
message_subscribe
module for sending. When configuring message_subscribe to not use the queue for sending (as possible inadmin/config/system/message-subscribe
), the issue went away. Otherwise, we would have a stuck job in the message_subscribe queue, as shown bydrush queue-list
. It was stuck, because it would not go away after running the queue withdrush queue-run message_subscribe
, but would send the same e-mails infinitely on every queue run.Comment #4
bsandor CreditAttribution: bsandor commentedComment #10
tripper54 CreditAttribution: tripper54 commentedI have just encountered this issue, processing a queue with drush queue-run which has an array of uids populated by a custom module.
The issue with patch #1 is if the processing run doesn't get through your list of users: either the number of users is greater than the range (default 100), or the task times out before finishing with all the users.
In this case, another queue item should be created with an array of the users that the first run didn't get to.
So what if, after sending the message, we remove the user element from the $subscribe_options['uids'] array:
Note there is a 'last uid' data point in the queue item saved after the run, but that is never referenced.
Comment #11
tripper54 CreditAttribution: tripper54 commentedPatch attached using this method.
Comment #12
klaasvw CreditAttribution: klaasvw as a volunteer and at Randstad Digital commentedThe above patch worked for me.
I refactored the code slightly:
Comment #13
oturpin CreditAttribution: oturpin commentedHi All,
I have the issue. But I am not sure that the intent of the developper was to reduce the $subscribe_options array whan message is sent. If I understand the code, the last_uid is stored and then used for next queue to proceed the uids over the last_uid up to range.
The code has a bug that make the queue starts all over again to index 0. Please, see that topic .
Waiting for your feedback !
Comment #14
oturpin CreditAttribution: oturpin commentedHi All,
@klaasvw : I like the approach. It simply works. I removed the last_uid logic from the code and from the queue. It runs OK.
Thx for your fix !
Comment #15
amitaibuWould it be possible to add a simpleTest to confirm the behavior of the queues?
Comment #16
bluegeek9 CreditAttribution: bluegeek9 as a volunteer commented