diff --git a/apachesolr.index.inc b/apachesolr.index.inc
index b7479cf..548519e 100644
--- a/apachesolr.index.inc
+++ b/apachesolr.index.inc
@@ -1109,7 +1109,7 @@ function apachesolr_floatval($value) {
  *  Indexing callback for the node_reference module
  *  by the references module
  */
-function apachesolr_nodereference_indexing_callback($entity, $field_name, $index_key, $field_info) {
+function apachesolr_nodereference_indexing_callback($entity, $field_name, $index_key, $field_info, $entity_type) {
   $fields = array();
   if (!empty($entity->{$field_name})) {
     $index_key = apachesolr_index_key($field_info);
@@ -1131,7 +1131,7 @@ function apachesolr_nodereference_indexing_callback($entity, $field_name, $index
  *  Indexing callback for the user_reference module
  *  by the references module
  */
-function apachesolr_userreference_indexing_callback($entity, $field_name, $index_key, $field_info) {
+function apachesolr_userreference_indexing_callback($entity, $field_name, $index_key, $field_info, $entity_type) {
   $fields = array();
   if (!empty($entity->$field_name)) {
     $index_key = apachesolr_index_key($field_info);
@@ -1152,13 +1152,13 @@ function apachesolr_userreference_indexing_callback($entity, $field_name, $index
 /**
  * Indexing callback for entityreference fields.
  */
-function apachesolr_entityreference_indexing_callback($entity, $field_name, $index_key, $field_info) {
+function apachesolr_entityreference_indexing_callback($entity, $field_name, $index_key, $field_info, $entity_type) {
   $fields = array();
   if (!empty($entity->{$field_name})) {
 
     // Gets entity type and index key. We need to prefix the ID with the entity
     // type so we know what entity we are dealing with in the mapping callback.
-    $entity_type = $field_info['field']['settings']['target_type'];
+    $target_entity_type = $field_info['field']['settings']['target_type'];
     $index_key = apachesolr_index_key($field_info);
 
     // Iterates over all references and adds them to the fields.
@@ -1167,7 +1167,7 @@ function apachesolr_entityreference_indexing_callback($entity, $field_name, $ind
         if ($id = (!empty($reference['target_id'])) ? $reference['target_id'] : FALSE) {
           $fields[] = array(
             'key' => $index_key,
-            'value' => $entity_type . ':' . $id,
+            'value' => $target_entity_type . ':' . $id,
           );
         }
       }
diff --git a/apachesolr.module b/apachesolr.module
index a9a7136..9888a93 100644
--- a/apachesolr.module
+++ b/apachesolr.module
@@ -2028,7 +2028,7 @@ function field_apachesolr_index_document_build(ApacheSolrDocument $document, $en
           if ($function && function_exists($function)) {
             // NOTE: This function should always return an array.  One
             // entity field may be indexed to multiple Solr fields.
-            $fields = $function($entity, $field_name, $index_key, $field_info);
+            $fields = $function($entity, $field_name, $index_key, $field_info, $entity_type);
             foreach ($fields as $field) {
               // It's fine to use this method also for single value fields.
               $document->setMultiValue($field['key'], $field['value']);
