For Drupal 7 and 8, search_get_info() defines the properties of each module, but there is no way to alter that.

A use case for altering it is to add a conditions callback to node_search_info() when something like facet API is enabled. Currently since there is no conditions callback, it's impossible to search just for items matching a facet filter. Instead, there must always be a non-empty keyword to do a node search.

Comments

pwolanin’s picture

Status: Active » Needs review
StatusFileSize
new438 bytes

Status: Needs review » Needs work

The last submitted patch, search-info-alter-1911276-1.patch, failed testing.

pwolanin’s picture

Status: Needs work » Needs review
StatusFileSize
new1.44 KB

I'm not sure what that failure is - looks like an upgrade path issue.

Here's a revised patch that adds API docs.

jhodgdon’s picture

Status: Needs review » Needs work

Thanks! Can we make a couple of changes to the documentation of the new hook?

a) Write out the word "information" instead of "info" in the first line.

b) Name the parameter something else. I realize that in the search module code, it is called $search_hooks, but that doesn't actually make much sense in the context of this hook documentation. How about $search_info or $search_type_info?

c) Describe better what is in the parameter array. hook_search_info() just lets you return one array of search information, which is well-described. This alter hook has an array of these items. So I think a better description would be something like:

Associative array of search type information, whose keys are the short names of the modules supplying the search types, and whose values are their return values from hook_search_info().

(Maybe that can be written in a better way, but something getting across that information would be better than what is in there now.)

d) And do we need a test for this new alter hook?

pwolanin’s picture

Status: Needs work » Needs review
StatusFileSize
new1.62 KB
jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

This looks like a straightforward fix to me, and I'm happy with the documentation. I think it might even be backportable to D7, which would probably make Solr happy? :)

pwolanin’s picture

Yes, I hope we can backport. For 7 it would make it easier to integrate Facet APi with core search - Apache Solr integration already provides a conditions callback, though this alter would let people modify it if needed.

xjm’s picture

#5: search-info-alter-1911276-5.patch queued for re-testing.

xjm’s picture

Category: bug » feature
Issue tags: +Needs backport to D7

I think this is technically a feature request, but I agree that it can be backported.

jhodgdon’s picture

Issue tags: -Needs backport to D7

#5: search-info-alter-1911276-5.patch queued for re-testing.

pwolanin’s picture

#5: search-info-alter-1911276-5.patch queued for re-testing.

Issue tags: +Needs backport to D7

The last submitted patch, search-info-alter-1911276-5.patch, failed testing.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, search-info-alter-1911276-5.patch, failed testing.

jhodgdon’s picture

Looks like we need a reroll of this patch.

pwolanin’s picture

Version: 8.x-dev » 7.x-dev
Status: Needs work » Patch (to be ported)

The alter is being handled in #2003482: Convert hook_search_info to plugin system for Drupal 8 per timplunkett, so moving this issue to Drupal 7

pwolanin’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new1.37 KB
jhodgdon’s picture

Status: Needs review » Needs work
Issue tags: -Needs backport to D7 +Needs tests

OK...

a) I think we need a test for this to verify it is working as documented.

b) I think a couple of small tweaks to the documentation would help:
- The @param should say it's an associative array keyed by the name of the module that provided hook_search_info().
- The sample function body should reference callback_search_conditions(), which is defined later in the search.api.php file (and provides a template for the conditions callback functions).

jhodgdon’s picture

Status: Needs work » Closed (won't fix)

At this point... We don't consider feature requests to D7 do we? So we should just drop this idea?