function notifications_process_prepare in Notifications 5
Same name and namespace in other branches
- 6 notifications.cron.inc \notifications_process_prepare()
- 6.2 notifications.cron.inc \notifications_process_prepare()
- 6.3 notifications.cron.inc \notifications_process_prepare()
Prepare subscriptions queue
This is intended to avoid race conditions where new rows are added while the process is running
Return value
Max $sqid that will be processed this cron
2 calls to notifications_process_prepare()
- Notifications_Content_Tests::testNotificationsContent in tests/
notifications_content.test - Play with creating, retrieving, deleting a pair subscriptions
- notifications_process_run in ./
notifications.cron.inc - Function to be called on cron by the main notifications_cron
File
- ./
notifications.cron.inc, line 107
Code
function notifications_process_prepare($module = 'notifications') {
// Clean up event table. As events are created sequentially, we use this fact to speed up the query
// This expiretime will prevent some race condition that occurs when the event is saved but the subs queue not yet populated
$expiretime = time() - 60;
db_query("DELETE FROM {notifications_event} WHERE created < %d AND eid < (SELECT MIN(eid) FROM {notifications_queue})", $expiretime);
// This will get the latest notification in queue so we don't mess with new ones being created during cron run
// It will also prevent clashes with the inmediate sending feature
return db_result(db_query("SELECT max(sqid) FROM {notifications_queue}"));
}