Closed (duplicate)
Project:
Apache Solr Attachments
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
28 Sep 2012 at 12:03 UTC
Updated:
8 Nov 2014 at 20:21 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
nick_vhSounds like corrupt data? Can you make this reproducible?
Comment #2
omaster commentedI thought it sounded like corrupt data which is why I removed and re-added everything to do with apache solr /attachments and entities. Nothing fixed it.
I am not sure how to make this reproducible.
Note the issue only appears once this module is enabled. Everything works find until Apache Solr Attachments is enabled.
Comment #3
omaster commentedDamn I went away from this module for this exact reason and then went to search API where I was getting mixed results so came back to this and apache solr and boom same error again.
Is there no one who knows what is happening?
Comment #4
retorque commentedI am seeing this issue when I save a taxonomy term with a new file attachment, but I don't see it when deleting attachments from taxonomy terms or updating a term with an attachment without changing anything. The file attachment does attach to the term in spite of the error.
EDIT: I am not seeing this error when submitting new file attachments on nodes - only on taxonomy terms (though I haven't done a lot of troubleshooting yet).
Comment #5
retorque commentedI added some logging around every call to entity_extract_ids(), and it appears the problem is occuring (in my case, at least) in the entity_extract_ids() call in _apachesolr_attachments_update_parent_entity() on line 556.
In entity_extract_ids() in common.inc, $info['entity keys']['bundle'] is either not set or is set to vocabulary_machine_name for nearly all of the entities I checked on term save, and where the bundle is set to vocabulary_machine_name, $entity->vocabulary_machine_name is set to a valid vocabulary machine name. In the final entity_extract_ids() call where the error occured, the bundle is set to 'type', which does not exist as a property of $entity (but $entity->vocabulary_machine_name is set, and the term id is the same as in previous calls).
At this point, I noticed that the $entity_type parameter for entity_extract_ids() is hardcoded to 'node' in _apachesolr_attachments_update_parent_entity(). I swapped it for $parent_entity_type, and I no longer get the error.
Removed line 556:
list($parent_entity_id, $parent_entity_vid, $parent_entity_bundle) = entity_extract_ids('node', $parent_entity);
Replaced with:
list($parent_entity_id, $parent_entity_vid, $parent_entity_bundle) = entity_extract_ids($parent_entity_type, $parent_entity);
At this point, I don't know what effect this change might have downstream, but I'm going to do a bit more testing and see if it might be safe to just swap all instances of hardcoded 'node' in calls to entity_extract_ids() with the appropriate variable. If it seems safe for my sites, I will submit a patch.
Comment #6
omaster commentedI have come back to this module again and boom problem again.
But now it is a new problem. i managed to get rid of some corruptness. Now i am getting.
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'entity_id' cannot be null: INSERT INTO {apachesolr_index_entities_file} (entity_type, entity_id, parent_entity_type, parent_entity_id, bundle, status, changed) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6); Array ( [:db_insert_placeholder_0] => file [:db_insert_placeholder_1] => [:db_insert_placeholder_2] => node [:db_insert_placeholder_3] => 738 [:db_insert_placeholder_4] => file [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => 1366804664 ) in apachesolr_attachments_add_file_usage() (line 215 of /var/www/html/sites/all/modules/apachesolr_attachments/apachesolr_attachments.index.inc).
Comment #7
omaster commentedOk back to the original problem after uninstall and reinstall.
Missing bundle property on entity of type node.
Comment #8
retorque commentedThere were 6 calls to entity_extract_ids(), but only two of them appear to have had the parent entity type hardcoded to 'node'.
To fix the second hardcoded entity type, in function apachesolr-attachments_node_solr_document(), I replaced this line:
list($parent_entity_id, $parent_entity_vid, $parent_entity_bundle) = entity_extract_ids('node', $parent_entity);
With this line:
list($parent_entity_id, $parent_entity_vid, $parent_entity_bundle) = entity_extract_ids($env_id, $parent_entity);
NOTE: The comments for this function suggest that the third argument should be $entity_type, but it is named $env_id instead. I don't see the variable actually getting used anywhere in the function, and it appears to actually contain the entity type, so if this actually works, I will rename it when I submit a patch unless one of the module maintainers would prefer I do not rename it.
/**
* Builds the file-specific information for a Solr document.
*
* @param ApacheSolrDocument $document
* The Solr document we are building up.
* @param stdClass $entity
* The entity we are indexing.
* @param string $entity_type
* The type of entity we're dealing with.
*/
function apachesolr_attachments_node_solr_document(ApacheSolrDocument &$document, $parent_entity, $env_id) {
Comment #9
retorque commentedSearch indexing appears to be running without generating errors, and I can save file attachments on taxonomy terms without generating errors, so here is a patch.
omaster - I suspect the hardcoded entity type in function apachesolr-attachments_node_solr_document() (comment #8) is more likely the cause of your problem rather than the one I posted in comment #5, so this patch may be worth trying if you have not already switched back to another module and the amount of content you have is relatively small (the site I need this for will take at least a full day to reindex when I move the fix to production). The patch addresses the hardcoded entity types in comments #5 and #8.
Comment #10
David_Rothstein commentedSeems like a possible duplicate of #2195095: Error when trying using a file field on entities on than nodes e.g. field collection item? (Well actually this issue is older, but that one is marked RTBC.)
Comment #11
omaster commentedI no longer work with the system involved in the issue so I can't test anymore. I will just have to assume it resolved it. But close it as a duplicate of that other one.