Skip to content

Instantly share code, notes, and snippets.

@rafaqz
Created May 23, 2014 11:43
Show Gist options
  • Save rafaqz/e204bed024f6e8e8f463 to your computer and use it in GitHub Desktop.
Save rafaqz/e204bed024f6e8e8f463 to your computer and use it in GitHub Desktop.
Patches drupal message subscribe module to fix queue
diff --git a/message_subscribe.module b/message_subscribe.module
index da35358..026a2dc 100755
--- a/message_subscribe.module
+++ b/message_subscribe.module
@@ -152,30 +152,26 @@ function message_subscribe_send_message($entity_type, $entity, Message $message,
message_notify_send_message($cloned_message, $options, $notifier_name);
// Check we didn't timeout.
- if ($use_queue && $subscribe_options['queue']['end time'] && time() < $subscribe_options['queue']['end time']) {
- continue 2;
+ if ($use_queue && $subscribe_options['queue']['end time'] && time() > $subscribe_options['queue']['end time']) {
+ // We timed out so add remaining items back to the queue.
+ $task = array(
+ 'mid' => $message->mid,
+ 'entity_type' => $entity_type,
+ 'entity_id' => $id,
+ 'notify_options' => $notify_options,
+ 'subscribe_options' => $subscribe_options,
+ 'context' => $context,
+ 'uid' => $last_uid,
+ );
+
+ $task['subscribe_options']['last uid'] = $last_uid;
+
+ // Create a new queue item, with the last user ID.
+ return $queue->createItem($task);
}
}
}
- if ($use_queue) {
- // Add item to the queue.
- $task = array(
- 'mid' => $message->mid,
- 'entity_type' => $entity_type,
- 'entity_id' => $id,
- 'notify_options' => $notify_options,
- 'subscribe_options' => $subscribe_options,
- 'context' => $context,
- 'uid' => $last_uid,
- );
-
- $task['subscribe_options']['last uid'] = $last_uid;
-
- // Create a new queue item, with the last user ID.
- $queue->createItem($task);
- }
-
return $message;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment