You are here

function mailchimp_cron in Mailchimp 7.4

Same name and namespace in other branches
  1. 8 mailchimp.module \mailchimp_cron()
  2. 5.2 mailchimp.module \mailchimp_cron()
  3. 5 mailchimp.module \mailchimp_cron()
  4. 6.2 mailchimp.module \mailchimp_cron()
  5. 6 mailchimp.module \mailchimp_cron()
  6. 7.5 mailchimp.module \mailchimp_cron()
  7. 7 mailchimp.module \mailchimp_cron()
  8. 7.3 mailchimp.module \mailchimp_cron()
  9. 2.x mailchimp.module \mailchimp_cron()

Implements hook_cron().

We don't use batch API calls currently as it would require sorting through a lot of options here. Instead, we will provide VBO functions to perform large unsubscribes and subscribes and specifically call the batch functions.

1 call to mailchimp_cron()
_mailchimp_cron_batch in includes/mailchimp.drush.inc
Callback function to run cron.
4 string references to 'mailchimp_cron'
mailchimp_admin_settings in includes/mailchimp.admin.inc
Return the Mailchimp global settings form.
mailchimp_subscribe in ./mailchimp.module
Subscribe a user to a Mailchimp list in real time or by adding to the queue.
mailchimp_unsubscribe_member in ./mailchimp.module
Unsubscribe a member from a list.
mailchimp_update_member in ./mailchimp.module
Update a members list subscription in real time or by adding to the queue.

File

./mailchimp.module, line 1729
Mailchimp module.

Code

function mailchimp_cron() {
  $queue = DrupalQueue::get(MAILCHIMP_QUEUE_CRON);
  $queue
    ->createQueue();
  $queue_count = $queue
    ->numberOfItems();
  if ($queue_count > 0) {
    $batch_limit = variable_get('mailchimp_batch_limit', 100);
    $batch_size = $queue_count < $batch_limit ? $queue_count : $batch_limit;
    $count = 0;
    while ($count < $batch_size) {
      if ($item = $queue
        ->claimItem()) {
        call_user_func_array($item->data['function'], $item->data['args']);
        $queue
          ->deleteItem($item);
      }
      $count++;
    }
  }
}