You are here

function _linkchecker_cleanup_comment_references in Link checker 6.2

Same name and namespace in other branches
  1. 5.2 linkchecker.module \_linkchecker_cleanup_comment_references()
  2. 7 linkchecker.module \_linkchecker_cleanup_comment_references()

Cleanup no longer used comment references to links in the linkchecker_comments table.

1 call to _linkchecker_cleanup_comment_references()
_linkchecker_add_comment_links in ./linkchecker.module
Add comment links to database.

File

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

Code

function _linkchecker_cleanup_comment_references($cid = 0, $links = array()) {
  if (empty($links)) {

    // Comment do not have links. Delete all references if exists.
    db_query("DELETE FROM {linkchecker_comments} WHERE cid = %d", $cid);
  }
  else {

    // The comment 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_comments reference table.
    db_query("DELETE FROM {linkchecker_comments} WHERE cid = %d AND lid NOT IN (SELECT lid FROM {linkchecker_links} WHERE urlhash IN (" . db_placeholders($links, 'varchar') . "))", array_merge(array(
      $cid,
    ), array_map('md5', $links)));
  }
}