You are here

function _linkchecker_cleanup_block_custom_references in Link checker 7

Cleanup no longer used custom block references to links in the linkchecker_block_custom table.

Parameters

int $bid: The block ID.

array $links:

1 call to _linkchecker_cleanup_block_custom_references()
_linkchecker_add_block_custom_links in ./linkchecker.module
Add custom block links to database.

File

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

Code

function _linkchecker_cleanup_block_custom_references($bid = 0, $links = array()) {
  if (empty($links)) {

    // Block do not have links. Delete all references if exists.
    db_delete('linkchecker_block_custom')
      ->condition('bid', $bid)
      ->execute();
  }
  else {

    // The block still have more than one link, but other links may have been
    // removed and links no longer in the content need to be deleted from the
    // linkchecker_block_custom reference table.
    $subquery = db_select('linkchecker_link')
      ->fields('linkchecker_link', array(
      'lid',
    ))
      ->condition('urlhash', array_map('drupal_hash_base64', $links), 'IN');
    db_delete('linkchecker_block_custom')
      ->condition('bid', $bid)
      ->condition('lid', $subquery, 'NOT IN')
      ->execute();
  }
}