You are here

function scheduler_cron in Scheduler 7

Same name and namespace in other branches
  1. 8 scheduler.module \scheduler_cron()
  2. 5 scheduler.module \scheduler_cron()
  3. 6 scheduler.module \scheduler_cron()
  4. 2.x scheduler.module \scheduler_cron()

Implements hook_cron().

6 calls to scheduler_cron()
drush_scheduler_cron in ./scheduler.drush.inc
Run lighweight scheduler cron.
SchedulerApiTestCase::testAllowedPublishing in tests/scheduler_api.test
Tests hook_scheduler_allow().
SchedulerFunctionalTest::testPastDates in tests/scheduler.test
Test the different options for past publication dates.
SchedulerTestBase::helpTestScheduler in tests/scheduler.test
Helper function for testScheduler(). Schedules content and asserts status.
SchedulerTestBase::schedule in tests/scheduler.test
Simulates the scheduled (un)publication of a node.

... See full list

1 string reference to 'scheduler_cron'
scheduler_cron_is_running in ./scheduler.module
Return whether Scheduler cron is running.

File

./scheduler.module, line 693
Scheduler publishes and unpublishes nodes on dates specified by the user.

Code

function scheduler_cron() {

  // Load the cron functions file.
  module_load_include('inc', 'scheduler', 'scheduler.cron');

  // During cron runs we do not want i18n_sync to make any changes to the
  // translation nodes, 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 cron processing, then restore the setting afterwards.
  // @todo Replace this workaround with a hook implementation when issue
  //   #2136557 lands.
  // @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
  // Scheduler cron. Set the default value to FALSE, then turn on the flag.
  // @see scheduler_cron_is_running()
  $scheduler_cron =& drupal_static(__FUNCTION__, FALSE);
  $scheduler_cron = TRUE;

  // If the option is enabled clear caches if a node was published or
  // unpublished, just like it would have been done if system_cron ran or the
  // nodes were edited through the node edit form.
  $nodes_published = _scheduler_publish();
  $nodes_unpublished = _scheduler_unpublish();
  if (variable_get('scheduler_cache_clear_all', 0) && ($nodes_published || $nodes_unpublished)) {

    // Clear the page and block caches.
    cache_clear_all();
    watchdog('scheduler', 'Page and block caches cleared.', array(), WATCHDOG_NOTICE, l(t('settings'), 'admin/config/content/scheduler'));
  }

  // 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;
}