diff --git a/apachesolr.api.php b/apachesolr.api.php
index f0e9c96..93b1f5b 100755
--- a/apachesolr.api.php
+++ b/apachesolr.api.php
@@ -385,10 +385,13 @@ function hook_apachesolr_index_document_build_ENTITY_TYPE(ApacheSolrDocument $do
  *
  * @param $documents
  *   Array of ApacheSolrDocument objects.
- * @param $entity
+ * @param $context
+ *   Array of entity, entity_id and env_id
  * @param $entity_type
  * @param string $env_id
  */
-function hook_apachesolr_index_documents_alter(array &$documents, $entity, $entity_type, $env_id) {
-  // Do whatever altering you need here
+function hook_apachesolr_index_documents_alter(array $documents, $context = array()) {
+  // extract gives you $entity, $entity_id and $env_id
+  extract($context);
+  // Do whatever altering you need here on the documents
 }
\ No newline at end of file
diff --git a/apachesolr.index.inc b/apachesolr.index.inc
index 6be0112..862589c 100644
--- a/apachesolr.index.inc
+++ b/apachesolr.index.inc
@@ -187,7 +187,7 @@ function apachesolr_index_entity_to_documents($item, $env_id) {
   }
 
   // Now allow modules to alter each other's additions for maximum flexibility.
-  drupal_alter('apachesolr_index_documents', $documents, $entity, $entity_type, $env_id);
+  drupal_alter('apachesolr_index_documents', $documents, array('entity' => $entity, 'entity_type' => $entity_type, 'env_id' => $env_id));
 
   // Restore the user.
   $user = $saved_user;
