Closed (fixed)
Project:
Profile2 Apachesolr
Version:
7.x-1.2
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
14 Sep 2012 at 04:10 UTC
Updated:
6 Mar 2013 at 18:10 UTC
Jump to comment: Most recent file
Comments
Comment #1
asgorobets commentedThis is really a problem with the code:
The indexing works if you do a full reindex, and it's not working as expected on hook_entity_insert and hook_entity_update.
Apachesolr module provides a good way of thinking and a good API for other modules to implement.
I've found that in the code:
The author is trying to implement his own reindexing mechanism instead of using apachesolr default. It's not working since apachesolr_mark_entity will do a db_update for a $profile->pid that's not yet in DB.
In this case profile2_apachesolr_profile2_insert will do nothing useful:
You got it right, the apachesolr_mark_entity will mark an entity for reindexing. But an existing one. It's useful to use it when you're posting a comment on a node and want to reindex node instead. Like here:
It's not really needed to use apachesolr_mark_entity to reindex the updated entity itself because apachesolr module already have a mechanism of doing this:
Take a look at this:
In this case db_merge will not only update a table with new values, but can also insert values. There is also a apachesolr_entity_insert hook that's calling the
apachesolr_entity_update function. This will index all the entities that were inserted or updated.
For this thing to work properly you have to set some values in $entity_info to notify apachesolr_entity_should_index function that the entity should be indexed:
The author did set some changes in hook_entity_info_alter():
As you can see the $entity_info['profile2']['apachesolr']['bundles'][$bundle_name]['index'] is wrong according to $info['bundles'][$bundle]['apachesolr']['index'] from apachesolr_entity_should_index function. Probably the apachesolr module was changed and this thing worked before, but it looks like the issue was reported from version 1.2 and is pretty old.
I did a patch to fix this issue as well as clean-up the project from unnecessary functions mentioned above.
I would also like to contribute to the module since it's been a while since the module was updated. You can make a maintainer if you feel that you don't have too much time for the project.
Thank You,
Alexei.
Comment #2
asgorobets commentedComment #4
pwaterz commentedLet me get this tested and will update it
Comment #5
asgorobets commentedHi, I've improved a little bit the patch to avoid some notices and to use proper apachesolr API hook for updating entity_info.
In case the patch will not apply it's because of different line endings, you can use:
git am --ignore-space-change indexing-on-insert-not-working-1784296-5.patch
Comment #7
Ingmar commentedPlease try to get this working. I could use this definitely!
Thanks for your effort!
Comment #8
pwaterz commented@ingmar, why dont you try and patch and test it your self :)
Comment #9
pwaterz commented@asgobets
why did you do this?
-function profile2_apachesolr_entity_info_alter(&$entity_info) {
- $entity_info['profile2']['apachesolr']['indexable'] = TRUE;
- $entity_info['profile2']['apachesolr']['status callback'][] = 'profile2_apachesolr_profile2_status_callback';
- $entity_info['profile2']['apachesolr']['document callback'][] = 'profile2_apachesolr_solr_document_profile2';
- $entity_info['profile2']['apachesolr']['reindex callback'] = 'profile2_apachesolr_solr_reindex_profile2';
- $entity_info['profile2']['apachesolr']['index_table'] = 'apachesolr_index_entities_profile2';
+function profile2_apachesolr_apachesolr_entity_info_alter(&$entity_info) {
+ $entity_info['profile2']['indexable'] = TRUE;
+ $entity_info['profile2']['status callback'][] = 'profile2_apachesolr_profile2_status_callback';
+ $entity_info['profile2']['document callback'][] = 'profile2_apachesolr_solr_document_profile2';
+ $entity_info['profile2']['reindex callback'] = 'profile2_apachesolr_solr_reindex_profile2';
+ $entity_info['profile2']['index_table'] = 'apachesolr_index_entities_profile2';
+}
I dont think that is right.
Comment #10
pwaterz commentedAhh i see now, you are correct.
Comment #11
pwaterz commentedI tried to apply the patch and it failed.
error: patch failed: profile2_apachesolr.module:1
error: profile2_apachesolr.module: patch does not apply
Comment #12
asgorobets commentedI see, there's an issue with line endings, your files in repository have CRLF line endings and the patch is LF line endings.
Using git am --ignore-space-change indexing-on-insert-not-working-1784296-5.patch works for me. Did you tried that?
There are some issues describing the problem that you will want to take a look at:
Provide Git core.*crlf settings recommendations based on OS sniffing
CRLF line endings cause problems with "git apply"
Maybe the files should be converted to LF for convenience.
Comment #13
pwaterz commentedInteresting, I use eclipse for development. I'll see if I can fix that.
Comment #14
pwaterz commentedI added a dev branch release, and committed this patch there.
Comment #15
asgorobets commentedThanks pwaterz!
Comment #16
pwaterz commentedIn release 7.x-1.6