When I search using the drupal search I get directed to the search/location results page, even though I do not have the location search module enabled.

It seems to be due to the location_search function in location.module running even though I am not using the location_search module.

I have attached a patch that fixes this problem. It is against 6.x-3.x-dev.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Agileware’s picture

Here is a slightly better patch along with the same patch for 5.x-3.x-dev

bdragon’s picture

Status: Needs review » Needs work

Calling module_exists in global scope is a very bad idea, as is selectively defining functions.

Agileware’s picture

I agree that it isn't the best idea but the way it works currently is also bad.
In the case of this hook function and the logic that determines whether or not the function exists I don't think it is dangerous even if it isn't really good practice.

Ideally hook_search should be in the location search module, not the location module.
The only issue then being the url, which is also annoying.

Agileware’s picture

Status: Needs work » Needs review

Thinking about this more, due to the conditions that this function is defined
or not and the hook function that is being defines I don't really think this poses an issue.

Also, I have seen other modules doing the same thing.
For example look at content.token.inc in the cck module.
It does exactly this with no negative effects.

YesCT’s picture

Status: Needs review » Postponed (maintainer needs more info)

Please check to see if this is still a problem in the new release. If it is, reply with a new summary and set the status back to active. and check to see if the patch needs a reroll against the new dev. Thanks.

jpmckinney’s picture

Status: Postponed (maintainer needs more info) » Needs review
// When search.module asks for name, return FALSE to tell it that we're disabled.

This is not part of the API http://api.drupal.org/api/function/hook_search/6

Although search.module may understand what to do when module_invoke($module, 'search', 'name') returns FALSE, few (if any) other modules do. For example, when the location and opensearch modules are both enabled, but location_search is disabled, opensearch believes there is a real implementation of hook_search by the location module, even though there is not. Among other things, it displays an empty row on its admin page where the name of the search should appear.

The patch in #1 is the same patch I came up with, and should be applied, as not following the API breaks things (more than I've listed here).

Agileware’s picture

Yeah, this is definitely still an issue in the latest version.

YesCT’s picture

jpmckinney, just to clarify, are you reviewing the patch and giving it a go?

jpmckinney’s picture

Status: Needs review » Reviewed & tested by the community

Yes, I guess I could have set it to RTBC :)

rooby’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 5, 6 & HEAD (Note that hook_search isn't in drupal 7 but I committed it anyway so the versions are kept in line until the d7 version is properly ported)
http://drupal.org/cvs?commit=429442
http://drupal.org/cvs?commit=429440
http://drupal.org/cvs?commit=429456
[EDIT: changed the url for the HEAD commit to the correct one]

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.