This watchdog line in search.pages.inc (around line 28) is trying to invoke hook_search() and should maybe/probably be using hook_search_info now?

    if (trim($keys)) {
      // Log the search keys:
      watchdog('search', '%keys (@type).', array('%keys' => $keys, '@type' => module_invoke($type, 'search', 'name')), WATCHDOG_NOTICE, l(t('results'), 'search/' . $type . '/' . $keys));

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhodgdon’s picture

Status: Active » Needs review
FileSize
928 bytes

This should fix that watchdog entry.

jhodgdon’s picture

Just as a clarifying note, hook_search() no longer exists in Drupal 7. It was broken up into different hooks, and hook_search_info() is the one where a search-activated module tells Search what the name of its search is.

jhodgdon’s picture

Title: search module is still trying to invoke hook_search() » search module watchdog entry is missing search type
FileSize
9.18 KB
9.73 KB

See attached screen shots of watchdog log entry details without and with this patch. The format of the message is
keys (search type).
(I searched for "abc" in both cases).

Dries’s picture

The "(Content)" part is confusing/redundant to me. Can't it be removed?

jhodgdon’s picture

That is what the message did in D6 - it showed whether you were searching for content or users or whatever (e.g. some custom search module provided a search type). Are you sure you want it removed? Another option would be to format the message something like:

Searched for ____ in _____

Maybe that would be clearer?

Current message if you search in "Users" instead of "Content":

abc (Users).

jhodgdon’s picture

And just as a note, all my patch did was restore the functionality that was already there, but which wasn't working because whoever updated all the search hooks missed this one call.

Dries’s picture

Maybe the type should be 'user search' vs 'content search'?

jhodgdon’s picture

FileSize
7.57 KB

The type string (User or Content) is coming from what the module provides in hook_search_info(), and is the same as the tabs/links provided on the main search page. I am not sure just adding "search" after it would be appropriate for all search sub-modules, as it is never displayed that way on the main search page (see attached screen shot of search page).

Here are some variations I can think of (keep in mind that Content and User are the two core possibilities for display of the Type):

1. abc (Content)
2. Searched for abc in Content
3. Searched abc in Content
4. Search: abc in Content
5. Search: abc (in Content)
6. Searched Content for abc
7. Keys: abc (Type: Content)
8. Keys: abc (Search type: Content)
9. Keys: abc (in Content)

#1 is the current/D6 version. I think #6 is my current personal favorite. Any of those (or another variation) seem reasonable to you? Keep in mind that the log also shows "search" as the log entty type in the log, so putting the word "search" in the log entry may not be necessary... Still, I think most Drupal messages are a bit more verbose than #1.

Dries’s picture

The type string comes from watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $link = NULL). It might not be best to create more types though so let's just pick one of your suggestions.

jhodgdon’s picture

Assigned: jhodgdon » Unassigned
Status: Needs work » Needs review

OK. I'll make a patch with message variation #6 later today tomorrow, unless you have a preference for one of the others. Just about anything would be an improvement over the cryptic D6 message (variation #1).

jhodgdon’s picture

Assigned: Unassigned » jhodgdon
Status: Needs review » Needs work
jhodgdon’s picture

Assigned: Unassigned » jhodgdon
Status: Needs review » Needs work
FileSize
1.09 KB

Here's a patch that makes the message:
Searched Content for abc
Searched Users for abc

jhodgdon’s picture

Assigned: jhodgdon » Unassigned
Status: Needs work » Needs review
Dries’s picture

I think we should use %type instead of @type because otherwise the capitalization looks funny. Not?

jhodgdon’s picture

FileSize
1.09 KB

Agreed. %type makes the message:
Searched Content for abc.
Definitely better.

Attached patch.

Dries’s picture

Status: Needs review » Fixed

Great. Committed to CVS HEAD. Thanks.

Status: Fixed » Closed (fixed)

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