All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

Solspace Tag issue when searching for tag_name that doesn't exist

Sten Van den Bergh 20 Dec 2016 15:25 problem, complete

When I'm searching for a tag_name that doesn't exist I'm getting all results instead of 0. When searching for a tag_name that does exist but isn't linked to any of the entries withing the collection it is working as expected and returning 0 entries.

I'm working with Solspace Tag and Low Search 4.4.4 on eecms 2.6.1

Replies

  1. Low 21 Dec 2016 12:57

    Yeah, I see how that can be an issue. To fix, open up /low_search/filters/tags/lsf.tags.php and look up line #96, which reads

    $tag_map = low_flatten_results($query->result_array(), 'tag_id', 'tag_name');


    below that, add this new line:

    if (empty($tag_map)) return array();


    ...which should trigger the no results if unknown tag names are given.

    Sten Van den Bergh 21 Dec 2016 13:04

    That seems to trigger the no_results even when no search query was entered (I'm using the Low Search Results tag even if no search was entered as a replacement for channel:entries)

    Low 21 Dec 2016 13:05

    Odd, as that script would only be triggered if the tag filter is fired. Will test some more.

  2. Low 21 Dec 2016 13:28

    Okay, in addition to the above, change lines 50 and 51, which now read

    $tag_names = $this->params->get_prefixed('tag_name'); 
    $tag_ids = $this->params->get_prefixed('tag_id');


    to

    $tag_names = array_filter($this->params->get_prefixed('tag_name'), 'low_not_empty'); 
    $tag_ids = array_filter($this->params->get_prefixed('tag_id'), 'low_not_empty');


    ...does that help?

    Sten Van den Bergh 21 Dec 2016 13:36

    That does get me my results back when no search is entered, but still results in all entries when searching for a tag_name that doesn't exist.

    Low 21 Dec 2016 13:37

    You did keep the first change, right?

    Sten Van den Bergh 21 Dec 2016 13:48

    Almost there, something weird happening now. I now get the expected behaviour when looking for a random tag that doesn't exist. But this still happens: when looking for a tag that exists (but isn't linked to any of the entries) in all caps (when the actual tag is all lowercase) I'm getting all results. Hoping this makes sense to you.. thanks a lot for the previous fix already!

    Low 21 Dec 2016 14:00

    Drop me an email at hi at gotolow dot com and I'll send you a patched version of the filter.

    Sten Van den Bergh 21 Dec 2016 14:17

    Your latest patch did the trick, thanks!