You are here

function linkchecker_cron in Link checker 6.2

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. 7 linkchecker.module \linkchecker_cron()

Implementation of hook_cron().

File

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

Code

function linkchecker_cron() {

  // Remove outdated links no longer in use once per day.
  if (time() - variable_get('linkchecker_cleanup_links_last', 0) >= 86400) {
    _linkchecker_cleanup_links();
    variable_set('linkchecker_cleanup_links_last', 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();
}