We have problem with report "Top search phrases with no results" (no results).

In this code (in apachesolr_stats_generate_report_elements):

// Count keywords with zero results; but only when no filters issued.
if ($record->numfound == 0 && (!$record->filters)) {
 @$keywords_noresults[$keys_filtered]++;
}

variable $record->filters is set to 'a:0:{}'. May code should look like this:

// Count keywords with zero results; but only when no filters issued.
if ($record->numfound == 0 && (!$record->filters || $record->filters == 'a:0:{}')) {
 @$keywords_noresults[$keys_filtered]++;
}
CommentFileSizeAuthor
#2 zero-results-1368926-2.patch1.6 KBcpliakas

Comments

cpliakas’s picture

Status: Needs review » Needs work

Instead of testing for the string, it might be useful to unserialize the array since it is already done in that loop once. We could unserialize it at the top of the loop, store it in a variable, and then use the variable in both places.

cpliakas’s picture

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

The attached patch unserializes the filters at the top and stores them in a variable for reuse.

janusman’s picture

This looks good. I'm a bit busy moving to boston this next week but I think I can probably take a better look at this soon.

cpliakas’s picture

Understood. Welcome to the area! I have lived outside of Boston most of my life, so maybe I will see you around at a local Drupal event sometime.

Good luck with the move,
Chris

cpliakas’s picture

Status: Needs review » Fixed
janusman’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Status: Fixed » Active

I think this actually needs backporting =)