Skip to content
Snippets Groups Projects

Issue #3086125 by bluegeek9: Prevent infinite loop when sending messages with queue

1 file
+ 15
3
Compare changes
  • Side-by-side
  • Inline
+ 15
3
@@ -177,9 +177,13 @@ class Subscribers implements SubscribersInterface {
@@ -177,9 +177,13 @@ class Subscribers implements SubscribersInterface {
if ($subscribe_options['uids']) {
if ($subscribe_options['uids']) {
// We got a list of user IDs directly from the implementing module,
// We got a list of user IDs directly from the implementing module,
// However we need to adhere to the range.
// However we need to adhere to the range.
$uids = $subscribe_options['range'] ? array_slice($subscribe_options['uids'], 0, $subscribe_options['range'], TRUE) : $subscribe_options['uids'];
$offset = 0;
}
if ($subscribe_options['last uid']) {
 
$offset = array_search($subscribe_options['last uid'], array_keys($subscribe_options['uids'])) + 1;
 
}
 
$uids = $subscribe_options['range'] ? array_slice($subscribe_options['uids'], $offset, $subscribe_options['range'], TRUE) : $subscribe_options['uids'];
 
}
if (empty($uids) && !$uids = $this->getSubscribers($entity, $message, $subscribe_options, $context)) {
if (empty($uids) && !$uids = $this->getSubscribers($entity, $message, $subscribe_options, $context)) {
// If we use a queue, it will be deleted.
// If we use a queue, it will be deleted.
return;
return;
@@ -231,7 +235,15 @@ class Subscribers implements SubscribersInterface {
@@ -231,7 +235,15 @@ class Subscribers implements SubscribersInterface {
}
}
}
}
if ($use_queue) {
$last_key = key(array_slice($subscribe_options['uids'], -1, 1, TRUE));
 
 
// Last key could not be found which means there are no more queue items to
 
// create.
 
if ($last_key === NULL) {
 
return;
 
}
 
 
if ($use_queue && isset($last_uid) && $last_key != $last_uid) {
// Add item to the queue.
// Add item to the queue.
$task = [
$task = [
'message' => $message,
'message' => $message,
Loading