You are here

function notifications_process_run in Notifications 6.2

Same name and namespace in other branches
  1. 5 notifications.cron.inc \notifications_process_run()
  2. 6 notifications.cron.inc \notifications_process_run()
  3. 6.3 notifications.cron.inc \notifications_process_run()

Function to be called on cron by the main notifications_cron

It will call each subscription_process for each interval a number of times

This should send out messages starting with immediate delivery. We send first immediate delivery because the other ones can be added up for each period. Assumption: The bigger the interval, the longer delay it may admit (?) I.e. sending hourly email after 1 hour 15 mins may be ok if the system is overloaded.

2 calls to notifications_process_run()
notifications_admin_queue_process in ./notifications.admin.inc
Queue operations callback
notifications_cron in ./notifications.module
Implementation of hook_cron()
1 string reference to 'notifications_process_run'
notifications_queue_operations in ./notifications.admin.inc
List of queue operations

File

./notifications.cron.inc, line 31

Code

function notifications_process_run($cron = TRUE) {
  notifications_log('Starting notifications process');
  notifications_process('start');

  // There may be special time adjustments for cron
  if ($cron) {
    notifications_process('cron');
  }
  $stop = FALSE;
  $send_intervals = _notifications_send_intervals();
  unset($send_intervals[-1]);
  if ($max_sqid = notifications_process_prepare()) {
    foreach ($send_intervals as $interval => $name) {
      notifications_log('Processing queue', array(
        'send interval' => $name,
      ));
      while (notifications_process_queue($interval, $max_sqid)) {
        $stop = !notifications_process('check');
      }
      if ($stop) {
        notifications_log('Process stopped, reached processing limits');
        break;
      }
      else {
        notifications_log('Process finished', array(
          'send interval' => $name,
        ));
      }
    }
  }
  else {
    notifications_log('No rows in queue');
  }
}