jkndrkn
Forum Replies Created
-
Hi Mikko, I found two cases in our codebase where we had added totally custom hooks to the_content that failed to return content in some cases. It turns out that this issue was not related to Impreza or any other plugin at all. Thank you so much for walking me through this challenging bug!
> So if you remove the apply_filters() from that line, you get all the results returned as expected, just without any features added by the_content?
Correct. If I remove the line containing apply_filters() and replace it with the line containing do_shortcode() I do see all the results returned minus the features added by the_content.
I am working on a big multisite with lots of priority 10 hooks on the_content and have started going through each hook and disabling it one at a time until I discover the one that is introducing a problem. Could be Impreza or could be something else. Looks like we are on the same page about how to identify this issue.
Thank you for your continued responsiveness and patience with this issue :] Once I identify the plugin(s) that are breaking the search I will post my findings here in hopes that they will be useful to others.
I am working with an UpSolutions (Impreza) dev and they pointed me to this file:
According to them, on line 54 content is being discarded by this call:
echo apply_filters( 'the_content', $search_page->post_content );
The following line does successfully return content but breaks filters that rely on the_content:
echo do_shortcode($search_page->post_content);
I commented-out the three places in the relevanssi sources that add hooks to this filter. I also disabled all of the LearnDash plugins because these plugins add a lot of hooks to this filter.
This did not seem to help.
Have you seen this particular issue before?
I also compared all of the relevanssi and WP_Query->get_posts() for search terms that *do* return results and search terms that *do not* return results and it appears that the queries are identical across both successful and unsuccessful searches.
Have any ideas?
- This reply was modified 3 years, 11 months ago by jkndrkn.
Thank you, Mikko. I am going to continue concentrating on the theme. Thanks!
Hi Mikko, thank you for your response.
> What are the queries for relevanssi_search()?
Below is the second query per your instructions. It returns 414 rows when I run it on the MySQL prompt. The same search on the admin backend returns 430 rows. Perhaps the search parameters between front-end and back-end are different.
SELECT DISTINCT(relevanssi.doc), relevanssi.*, relevanssi.title * 5 + relevanssi.content * 1 + relevanssi.comment * 0.75 + relevanssi.tag * 0.75 + relevanssi.link * 0 + relevanssi.author + relevanssi.category * 0.75 + relevanssi.excerpt + relevanssi.taxonomy + relevanssi.customfield + relevanssi.mysqlcolumn AS tf FROM wp_26_relevanssi AS relevanssi WHERE relevanssi.term = 'knee' AND relevanssi.doc NOT IN (18731,18733,343) AND ((relevanssi.doc IN (SELECT DISTINCT(posts.ID) FROM wp_26_posts AS posts WHERE posts.post_type NOT IN ('revision', 'nav_menu_item', 'custom_css', 'customize_changeset', 'oembed_cache', 'user_request', 'wp_block', 'mp-reminder', 'memberpressrule', 'memberpresscoupon', 'acf-field-group', 'acf-field', 'product_variation', 'shop_order', 'shop_order_refund', 'shop_coupon', 'sfwd-question', 'sfwd-certificates', 'sfwd-transactions', 'us_grid_layout', 'us_header', 'us_content_template', 'us_page_block', 'ld-notification', 'tablepress_table', 'sfwd-essays', 'sfwd-assignment', 'groups', 'wp_stream_alerts'))) OR (doc = -1)) ORDER BY tf DESC LIMIT 500
> Are you using the FacetWP Relevanssi integration plugin?
I am not. The only Relevanssi plugin I am using is the “relevanssi” plugin.
> Is FacetWP used in the Relevanssi search or not?
I do not believe so, no. I disabled the FacetWP on my site to test and the issue persists.
I did notice one odd detail:
The front-end search fails for some searches but not others. “knee” fails to return any results. “hat” returns the same results in both admin search and front-end search. Do issues with themes cause this kind of problem, typically? Searches that fail for some search terms but not others?
Here is the complete list of queries and stack traces for all WP_Query->get_posts() calls:
https://docs.google.com/spreadsheets/d/1_mQoiqh8ihLjhrZSdkxaobIvgp16v9MwhUFjJmoTlRE/edit?usp=sharing
See anything suspicious? I do see that MemberPress and FacetWP are involved in the stack traces. Same thing with Advanced Custom Fields. These are essential plugins that we rely on. Could these be incompatible with Relevanssi?
By the way, any function prefixed with “us_” is part of Impreza.
To add to the above, Impreza support asked me to update to Impreza 7.14.2. I also updated Relevanssi to 4.12.5. I am experiencing the same behavior:
* Admin search works
* Live Preview with TwentyTwenty works
* Site search with Impreza does not workHi Mikko, thank you so much for taking the time to respond!
> If you use Query Monitor, do you see anything from Relevanssi?
Yes, I see the following when I click Queries > Queries By Caller:
relevanssi_search: 2 select queries
relevanssi_populate_array: 5 select queries> If you set the “Caller” to “Relevanssi”, does that bring up anything on the search results page?
Not sure exactly what you mean by this. In “Queries” I can set the “Caller” drop-down on the right to either relevanssi_search or relevanssi_populate_array and examine the exact queries that are being called but this does not affect the search results page. Example: https://imgur.com/pxhjCto
> Does this file exist and if it does, what’s in it?
Yes, the file does exist. It is
plugins/us-core/templates/search.php
.
These are the contents: https://pastebin.com/gu5JDxDW> If you try live previewing one of the Twenty* default themes, does the search work there?
Using TwentyTwenty in live preview mode I do see expected search results. For one of my terms, “knee”, I see 403 results in live preview VS 431 results in admin search.
Question: does it look to you like the Impreza theme is the cause of the issue? Would this be something to chat with Impreza support about? Thanks!