You are here

function linkchecker_cron in Link checker 7

Same name and namespace in other branches
  1. 8 linkchecker.module \linkchecker_cron()
  2. 5.2 linkchecker.module \linkchecker_cron()
  3. 5 linkchecker.module \linkchecker_cron()
  4. 6.2 linkchecker.module \linkchecker_cron()

Implements hook_cron().

File

./linkchecker.module, line 450
This module periodically check links in given node types, blocks etc.

Code

function linkchecker_cron() {

  // Remove outdated links no longer in use once per day.
  if (REQUEST_TIME - variable_get('linkchecker_cleanup_links_last', 0) >= 86400) {
    _linkchecker_cleanup_links();
    variable_set('linkchecker_cleanup_links_last', REQUEST_TIME);
  }

  // Run link checker in a new process, independent of cron.
  if (module_exists('httprl') && variable_get('linkchecker_check_library', 'core') == 'httprl') {

    // Setup callback options array; call _linkchecker_check_links() in the
    // background.
    $callback_options = array(
      array(
        'function' => '_linkchecker_check_links',
      ),
    );

    // Queue up the request.
    httprl_queue_background_callback($callback_options);

    // Execute request.
    httprl_send_request();

    // Exit here so we don't call _linkchecker_check_links() in this process.
    return;
  }

  // Run the link checks the normal way.
  _linkchecker_check_links();
}