Closed Ipstenu closed 5 months ago
Hi @Ipstenu
Thanks for creating the issue, and I'm very sorry for the delay in responding.
I'm trying to figure out how to replicate this issue as I am unfamiliar with VIP and Enterprise search. I will ask help from our development team to look into this issue in the coming days and keep you posted.
Hello @Ipstenu! We were able to reproduce the issue locally and we have identified the problem (some query variables are missing in the WP_Query::query_vars
array) and we are working on a solution. 🙂
@pls78 That's fantastic! Thank you :)
Hi @Ipstenu, some updates about this 🙂
Upon additional investigation it seems the problem is the approach ES_WP_Query
takes: as written in their documentation:
The gist of what happens whn you use WP_Query( 'es=true' ) is that on pre_get_posts, the query vars are sent to a new instance of ES_WP_Query. The query vars are then replaced with a simple post__in query using the IDs which Elasticsearch found.
What happens is that, once the query has been re-written to be a post__in
query, the WP_Query query_vars
array is not filled with the correct data (which should be based on the type of content being retrieved, e.g. category, tag... ).
Our frontend integration, which takes care of rendering the additional meta fields which goes missing relies on that missing data.
It is worth noting that I tried also to deactivate our plugin and just dumping the query_vars
array by hooking into wp_head
(which is the hook we user for the frontend integration), and the results are the same: some data is missing.
Do you perhaps know if this is expected behaviour (WP_Query query_vars
being changed)?
We have come up with a workaround, but the fact the WP_Query object gets changed might lead to other side effects that have not been discovered yet.
Do you perhaps know if this is expected behaviour (WP_Query query_vars being changed)?
I believe that's as expected from WP VIP. In this moment, we've not done any further changes.
In this case I think it would be more safe and maintainable if the VIP search adapter for ES_WP_Query
(or ES_WP_Query
itself?) would take care of re-instating the original data in the query_vars
array.
Being WP_Query
a core WordPress class, hacking its internal state might cause problems also with other plugins that uses it.
We have a workaround for your specific issue but, giving the fact that the problem is not in our plugin, I'd like to know your point of view on this and if changes can be made by your side.
@pls78 We have a contact with VIP and can bring this up (obviously we didn't write this code either). Do you have any connections with them as well?
@Ipstenu Yes, we'll ask about the issue in our shared Slack channel with Automattic.
@Ipstenu after talking to Automattic developers we have decided to proceed with the implementation of the aforementioned workaround.
(this is RELATED TO 19695 and covers ENTERPRISE Search)
Please give us a description of what happened
On VIP they have a fork they made for "Enterprise" Search - https://docs.wpvip.com/enterprise-search/
If you follow their directions here - https://docs.wpvip.com/enterprise-search/enable-non-search-queries/ - it breaks the meta (effectively making Yoast SEO's description, among other seo meta like twitter URLs, canonical URLs, SEO titles, etc empty).
So here, we would be turning ON their Enterprise Search for categories:
And when we do so, the description for categories vanishes. If you make it $query->is_author() then you lose the descriptions for Authors.
To Reproduce
Step-by-step reproduction instructions
Expected results
Actual results
Screenshots, screen recording, code snippet
Author Pages Meta Description is missing (and the title was wrong as well - it was the PRE Yoast title)
Category Pages
I don't know how obvious it is, but the meta desc and canonical URL are entirely gone, and much of the data is effectively the NON Yoastified versions 😞
Temporary (we hope) fix for Categories
The only workaround we found was to apply filters for all of the missing data:
Example Twitter Title fix:
Example Rel Link fix:
replace_customized_wpseo_snippets
simply performs the same replacements of snippets that Yoast normally does.Technical info
Used versions