The function apachesolr_index_node_solr_reindex() makes database calls to the node table, but the table name is not properly wrapped in curly brackets, so it doesn't work for prefixed tables.

Lines 831-849 of apachesolr.index.inc:

<?php
...
    if ($bundle) {
      // Leave status 0 rows - those need to be
      // removed from the index later.
      db_query("DELETE FROM {{$indexer_table}} WHERE entity_type = 'node' AND bundle = '%s' AND status = 1", array($bundle));
      // Mark all nodes of the specified content type for reindexing.
      $query = "INSERT INTO {{$indexer_table}} (entity_id, bundle, status, entity_type, changed) (
        SELECT n.nid AS entity_id, n.type AS bundle, n.status AS status, 'node' AS entity_type, %d AS changed
        FROM node n WHERE n.type = '%s' AND status = 1)";
      db_query($query, array(APACHESOLR_REQUEST_TIME, $bundle));
    }
    else {
      // Leave status 0 rows - those need to be
      // removed from the index later.
      db_query("DELETE FROM {{$indexer_table}} WHERE entity_type = 'node' AND status = 1");
      $query = "INSERT INTO {{$indexer_table}} (entity_id, bundle, status, entity_type, changed) (
        SELECT n.nid AS entity_id, n.type AS bundle, n.status AS status, 'node' AS entity_type, %d AS changed
        FROM node n WHERE status = 1)";
      db_query($query, array(APACHESOLR_REQUEST_TIME));
    }
...
?>
CommentFileSizeAuthor
#1 1915316-1.patch1.23 KBm.stenta

Comments

m.stenta’s picture

Status: Active » Needs review
StatusFileSize
new1.23 KB

Attached is a simple patch that fixes the issue.

kevin.dutra’s picture

Status: Needs review » Reviewed & tested by the community

This is a pretty innocuous change, so I'm going to mark this RTBC.

pwolanin’s picture

Title: Issue with prefixed node table » Indexing problem with prefixed node table
Status: Reviewed & tested by the community » Fixed

committed, thanks

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.