I'm not really sure why this is happening, and there is only one search phrase that produces it, so rather than patch it I'm asking here if anyone has any thoughts. I'm also not sure what is relevant so I'm documenting the evidence only

My search is three words (though another three word search doesn't produce the error, and removing either of the clean_words doesn't produce the error either).
eg: alpha beta gamma

For one result (of about 30) clean_words matches twice in the same place. The match is a combination of the clean words joined by underscores
eg: $clean_words is (alpha, gamma) and the matches are (alpha_beta_gamma_delta, alpha_beta_gamma_delta).

The resulting section and section_length arrays have different lengths and therefore I get the undefined offset error when looping over the result. As the contents of section are two offsets in the same place if I array_unique() them I get arrays of the correct length and therefore no error.

From fuzzysearch.module

    409   asort($section);
    410   ksort($section_length);
    411   $section = array_unique(array_values($section));
    412   $section_length = array_values($section_length);

Is this something that we need a check for? Is there another (rarer) situation in which array_unique() won't be enough?

CommentFileSizeAuthor
#3 fuzzysearch-1874040-3.patch500 bytesmario steinitz

Comments

queenvictoria’s picture

Issue summary: View changes

Fix the actual clean words and add other symptom.

mario steinitz’s picture

Issue summary: View changes
Status: Active » Postponed (maintainer needs more info)

I'll set this issue to 'Postponed (maintainer needs more info)', as I'm missing the search value you've been talking of six years ago.

If you still can remember your scenario, I'd love to provide an according fix.

mario steinitz’s picture

Status: Postponed (maintainer needs more info) » Active

I was actually able to reproduce the behavior with any word that matches two or more of the keywords. Setting back to active and continuing investigation.

mario steinitz’s picture

Status: Active » Reviewed & tested by the community
StatusFileSize
new500 bytes

The attached patch incorporates the suggested code change of @queenvictoria.

I ran diverse tests and couldn't reproduce the undefined offset errors anymore.

mario steinitz’s picture

Status: Reviewed & tested by the community » Fixed

Fixed and committed. Thanks for pointing out this issue and suggesting your workaround!

Status: Fixed » Closed (fixed)

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