You are here

function apachesolr_node_type in Apache Solr Search 6

Same name and namespace in other branches
  1. 5.2 apachesolr.module \apachesolr_node_type()
  2. 6.3 apachesolr.module \apachesolr_node_type()
  3. 6.2 apachesolr.module \apachesolr_node_type()

Implementation of hook_node_type().

Mark nodes as needing re-indexing if a node type name changes.

File

./apachesolr.module, line 272
Integration with the Apache Solr search application.

Code

function apachesolr_node_type($op, $info) {
  if ($op != 'delete' && !empty($info->old_type) && $info->old_type != $info->type) {

    // We cannot be sure we are going before or after node module.
    switch ($GLOBALS['db_type']) {
      case 'mysql':
      case 'mysqli':
        db_query("UPDATE {apachesolr_search_node} asn INNER JOIN {node} n ON asn.nid = n.nid SET asn.changed = %d WHERE (n.type = '%s' OR n.type = '%s')", time(), $info->old_type, $info->type);
        break;
      default:
        db_query("UPDATE {apachesolr_search_node} SET changed = %d WHERE nid IN (SELECT nid FROM {node} WHERE type = '%s' OR type = '%s')", time(), $info->old_type, $info->type);
        break;
    }
  }
}