You are here

function notifications_process_prepare in Notifications 6.2

Same name and namespace in other branches
  1. 5 notifications.cron.inc \notifications_process_prepare()
  2. 6 notifications.cron.inc \notifications_process_prepare()
  3. 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

3 calls to notifications_process_prepare()
NotificationsContentTests::testNotificationsContent in tests/notifications_content.test
Play with creating, retrieving, deleting a pair subscriptions
NotificationsLiteTests::testNotificationsLite in tests/notifications_lite.test
Test simple sending cases
notifications_process_run in ./notifications.cron.inc
Function to be called on cron by the main notifications_cron

File

./notifications.cron.inc, line 67

Code

function notifications_process_prepare() {

  // Clean up expired logs from queue if logging enabled
  if ($keep = variable_get('notifications_log', 0)) {
    db_query("DELETE FROM {notifications_queue} WHERE cron = 0 AND sent < %d", time() - $keep);
  }

  // Clean up event table
  notifications_event_clean();

  // 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 immediate sending feature
  return db_result(db_query("SELECT max(sqid) FROM {notifications_queue}"));
}