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.
Problem Statement
The SmsEvents::MESSAGE_QUEUE_POST_PROCESS
event will still get dispatched after SmsEvents::MESSAGE_OUTGOING_POST_PROCESS
and SmsEvents::MESSAGE_POST_PROCESS
are dispatched if the gateway happens to have skip_queue
TRUE.
Even though it is documented that skip_queue
is not recommended in production, this is still a WTF for development and testing where the post process event handlers would behave funny in a test (for instance).
Proposed resolution
Filter out messages that have passed through a gateway with skip_queue on before passing them through the MESSAGE_QUEUE_POST_PROCESS
event dispatch.
Comments
Comment #2
dpiThese events are not mutually exclusive.
All
MESSAGE_QUEUE*
events are guaranteed to run if you use ::queue. LikewiseMESSAGE_*_*_PROCESS
are guaranteed to run regardless of entry point (queue, incoming, outgoing). I think the\Drupal\Tests\sms\Kernel\SmsFrameworkProviderTest::testEvents*
test outline it pretty well. Specifically::testEventsQueueOutgoing
and::testEventsQueueOutgoingSkipQueue
SmsEvents::MESSAGE_QUEUE_POST_PROCESS
should always be run in the original::queue
request regardless of skip_queue value.Comment #3
dpiNot sure if this is a misunderstanding on either part.
Comment #4
almaudoh CreditAttribution: almaudoh commentedOk. That makes sense. But then the order of the events change, which may be problematic for consuming code.
Event sequence
skip_queue: true
skip_queue: false
Comment #5
dpiI think thats okay.
MESSAGE_QUEUE_POST_PROCESS is the only special case, i don't really expect many people to consume this event.
Comment #6
almaudoh CreditAttribution: almaudoh commentedWell, I was consuming it. That is why I wrote the bug report. And I needed the same behavior whether in test code (skip_queue == true) or in production (skip_queue == false).
Comment #7
dpiMost importantly the event is consistent. It is the last thing to execute after attempting to queue. Whether it actually was queued could be determined by:
Does that work for you?