You are here

function notifications_process_run in Notifications 6.3

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.2 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) {

  // If we are running on language split mode we'll get a language here, which switches automatically for cron
  // When we run the sending manually, the language is current language
  $language = notifications_process_language();
  notifications_log('Starting notifications process', array(
    'language' => $language ? $language->name : 'All',
  ));
  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 => $interval_name) {
      notifications_log('Processing queue', array(
        'send interval' => $interval_name,
      ));
      while (notifications_process_queue($interval, $max_sqid, $language)) {
        $stop = !notifications_process('check');
      }
      if ($stop) {
        notifications_log('Process stopped, reached processing limits');
        break;
      }
      else {
        notifications_log('Process finished', array(
          'send interval' => $interval_name,
        ));
      }
    }
  }
  else {
    notifications_log('No rows in queue');
  }

  // Advance the language, we don't mind whether we've reached limits, need to move on
  notifications_process_language(TRUE);
}