You are here

function auto_block_scheduler_cron in Auto Block Scheduler 7

Implements hook_cron().

File

./auto_block_scheduler.module, line 245
Scheduler publishes and unpublishes block on dates specified by the user.

Code

function auto_block_scheduler_cron() {

  // During cron runs we do not want i18n_sync to make any changes to the
  // translation blocks, as this affects processing later in the same cron job.
  // Hence we save the i18n_sync state here, turn it off for the duration of
  // scheduler block cron processing, then restore the setting afterwards.
  // @see https://drupal.org/node/1182450
  // @see https://drupal.org/node/2136557
  if (module_exists('i18n_sync')) {
    $i18n_sync_saved_state = i18n_sync();
    i18n_sync(FALSE);
  }

  // Use drupal_static so that any function can find out if we are running
  // tirgger cron. Set the default value to FALSE, then turn on the flag.
  $auto_block_scheduler_cron =& drupal_static(__FUNCTION__, FALSE);
  $auto_block_scheduler_cron = TRUE;
  _auto_block_scheduler_publish_cron();
  _auto_block_scheduler_unpublish_cron();

  // Reset the static scheduler_cron flag.
  drupal_static_reset(__FUNCTION__);

  // Restore the i18n_sync state.
  module_exists('i18n_sync') ? i18n_sync($i18n_sync_saved_state) : NULL;
}