Needs work
Project:
Apache Solr Search
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
12 Nov 2012 at 21:32 UTC
Updated:
16 Aug 2014 at 23:16 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
brianV commentedJust adding that #1838850: Solr indexing callback assumes field is added to a node is dependent on this patch.
Comment #2
nick_vhThis does not default back to node right? I'm a little concerned if we have handled all indexing callbacks with this? Is this fully backwards compatible with previous API?
Comment #3
brianV commentedNick:
I'm not sure I understand your questions, but I'll attempt to answer them anyways.
Apachesolr itself is completely generic in terms of the entities that it handles, at least insofar as these functions are concerned. If you check the patch, you will see that the extra parameter isn't even used by any of the field indexing callbacks that apachesolr includes.
The problem is when you deal with field like Geofield which need to fetch 'more' info for indexing purposes, and they use functions like field_info_instance() which require an entity type and bundle passed as arguments. In Geofield's case, they used 'node' as the entity type and looked for $node->type as the bundle.
Once they are able to get the entity type, then between the entity type, entity id, the bundle can be fetched with entity_extract_ids.
Comment #4
nick_vhI'll commit this asap, looks like there is no impact for correct usage of the API
Comment #5
nick_vhI'm still concerned what happens if this
Calls a function that is custom and does not support the entity_type argument. Should we find out how many argument a function can take to allow for maximum compatibility throughout the stable version of this module?
Comment #6
nick_vhComment #7
pwolanin commented@Nick_vh - not sure about your question. A user-space function will ignore extra params passed to it. Is that your concern?
Comment #8
brianV commentedI believe this is the exact conversation we had on IRC prior to you posting #4.
A quick test, if you would like to confim, is to just toss this into a PHP file and execute:
This will just print 'Hello', and won't throw any warnings, notices etc.
Also, this is why PHP provides functions like http://php.net/manual/en/function.func-get-args.php, as we may not always know what arguments are being passed to a function. If you search the drupal codebase for function_get_args(), you will see that there are actually a bunch of use cases where a function is called with arguments passed, despite none being defined in the function signature, and func_get_args() is used to fetch them.
Comment #9
jlk4p commentedI have a question. Is this patch part of the 7.x-1.2 version? I tried adding it and it did not work. So I thought it was in that version. But when I attempt to write a callback function for a custom field and pass it the 5 parameters noted above which includes $entity_type, I get an error that argument 5 is missing.
Comment #10
pwolanin commentedpatch doesn't apply to 7.x-1.x now
Comment #11
amontero