You are here

function _linkchecker_unpublish_nodes in Link checker 7

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

Unpublishes all nodes having the specified link id.

Parameters

int $lid: A link ID that have reached a defined failcount.

1 call to _linkchecker_unpublish_nodes()
_linkchecker_status_handling in ./linkchecker.module
Status code handling.

File

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

Code

function _linkchecker_unpublish_nodes($lid) {
  $result = db_query('SELECT nid FROM {linkchecker_node} WHERE lid = :lid', array(
    ':lid' => $lid,
  ));
  foreach ($result as $row) {

    // Explicitly don't use node_load_multiple() or the module may run
    // into issues like https://drupal.org/node/1210606. With this logic
    // nodes can be updated until an out of memory occurs and further
    // updates will be made on the remaining nodes only.
    $node = node_load($row->nid);
    $node->status = NODE_NOT_PUBLISHED;
    node_save($node);
    linkchecker_watchdog_log('linkchecker', 'Set @type %title to unpublished.', array(
      '@type' => $node->type,
      '%title' => $node->title,
    ));
  }
}