Serialize / unserialize query
-
Hi Mikko,
hope all is well with you.
I need to serialize the WP Query at the end of the Woo loop, and then un-serialize it at a later stage to re-run it and process the results in a different context / page.
Unfortunately, the un-serialized query returns an empty result set when Relevanssi is enabled. If I disable your plugin, the search results are the same between the original search and un-serialized one.
To give you an hint (if I may), the same happened with the BeRocket Advanced Ajax filters, which when enabled caused the search results to be different between the original and the un-serialized search. The solution was to add two custom properties to the WP Query object before serializing it:
global $wp_query;
$buffer_query = $wp_query->query_vars;
$buffer_query[‘bapf_apply’] = true; // BeRocket Custom property #1
$buffer_query[‘bapf_save_query’] = true; // BeRocket Custom property #2
$ser = serialize($buffer_query);
….I therefore wonder if I need to do the same for Relevanssi (or any processing of the WP Query before serializing it) in order to ensure the correct results.
Thanks in advance for your help!
M
- The topic ‘Serialize / unserialize query’ is closed to new replies.