Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pro search throws an error if using more than one results tag in a template, and you search by keyword #2435

Closed
agun opened this issue Oct 17, 2022 · 2 comments
Assignees

Comments

@agun
Copy link

agun commented Oct 17, 2022

Description of the problem
Using multiple {exp:pro_search:results} tags in a template, and then searching by "?keyword" the following error is thown:

Error Caught
Method name must be a string
Pro_search_words.php:201

How To Reproduce
Steps to reproduce the behavior:
On a single template, I have 1 {exp:pro_search:form} tag with a keyword search input, and a category select input. I also have 2 {exp:pro_search:results} tags, each using a different "collection", and then styling the results differently.

  1. When doing an initial load of the page (ie /services/ ), both {exp:pro_search:results} return ALL results from each collection (which is expected result, and works correctly).
  2. When doing a search using only categories (ie /services?category=123|456 ), both {exp:pro_search:results} work correctly and return the filtered results from each collection.
  3. When doing a search using a keyword (ie /services?keywords=test ), the error above is thrown.
  4. When doing a search with both categories and a keyword (ie /services?category=123|456&keywords=test ), the error above is thrown.

Error Messages

Error Caught
Method name must be a string
Pro_search_words.php:201

Environment Details:

  • Version: 7.1.6
  • PHP Version: 8.0.8
  • MySQL Version: 5.7.23
  • Web Server: Apache

Possible Solution
It appears that when running the "function stem($word)" multiple times, it only returns the $method = 'stem' the first time. Subsequent iterations (in my case just a second one), then $method = '' ... which results in the error. I appreciate that this isn't a possible solution, but it is the root cause of the issue.

@intoeetive
Copy link
Contributor

@agun I was not able to replicate this so far. Would you mind sharing your template code here?

@agun
Copy link
Author

agun commented Oct 24, 2022

No problem @intoeetive ... this is in a template called /filter/services.html :

{exp:pro_search:results
  collection="services_featured"
  disable="categories|member_data|category_fields|pagination"
  keywords:match="title"
  keywords:mode="any"
  keywords:inflect="yes"
  keywords:stem="yes"
  keywords:lang="en"
  limit="40"
  orderby="title"
  sort="asc"
}
  {if count == 1}
    <h2 class="font-serif text-2xl md:text-3xl">Statewide & major services</h2>
    <div class="w-24 my-4 h-[4px] bg-brand-teal"></div>
    <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 grid-flow-dense mt-8 gap-12 rounded">
  {/if}

  <a class="group" href="{page_url}" data-id="{entry_id}">
    {if icon}<i class="fa-solid {icon} text-brand-brightblue text-2xl pb-2"></i>{/if}
    <p class="group-hover:text-brand-red transition duration-300 text-lg pb-1 leading-normal font-semibold">{title}</p>
    <p class="text-gray-600">{hero_summary}</p>
  </a>

  {if count == total_results}
    </div>
    <div class="border-b-4 border-gray-100 my-12"></div>
  {/if}
{/exp:pro_search:results}



{exp:pro_search:results
  collection="services"
  disable="categories|member_data|category_fields|pagination"
  keywords:match="title"
  keywords:mode="any"
  keywords:inflect="yes"
  keywords:stem="yes"
  keywords:lang="en"
  limit="200"
  orderby="title"
  sort="asc"
}
  {if count == 1}
    <h2 class="font-serif text-2xl md:text-3xl">All services & clinics</h2>
    <div class="w-24 my-4 h-[4px] bg-brand-teal"></div>
  {/if}

  <a class="border-b border-gray-100 py-4 group block" href="{page_url}" data-id="{entry_id}">
    <p class="text-brand-brightblue font-semibold group-hover:text-brand-red">{title}</p>
    {if summary}<div class="text-gray-600">{summary}</div>{/if}
  </a>

{/exp:pro_search:results}

This is for a health related website, so doing a keyword search such as:
https://www.mydomain.com/filter/services/?keywords=brain

...will result in the error. Just using categories it works fine:

https://www.mydomain.com/filter/services/?category=27|28

If I remove one of the "results" tags, then it works fine with the keywords (and I do this with plenty of other places through the site ... news, general search, events, resources etc).

In Pro_search_words.php if I change line 201 from:

$method = $this->stemmer->pro_search_stem_method;

to:

$method = 'stem';

Then it all works fine (which is what I am doing until this is fixed in the core).

Cheers!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants