It’s something on your end. I do plugin development on a server that runs PHP 8.1.9, and Relevanssi works fine there. How exactly did Relevanssi stop working? Do you get any specific error messages?
Thread Starter
kspang
(@kspang)
Hi Mikko,
Thank you so much for your response! It is throwing a fatal error when trying to load suggestions while the user is typing. I will post the error messages below. If you don’t have a idea off the top of your head don’t worry about it, I haven’t looked into it very much yet so I don’t want to waste your time. Thanks again!
[16-Mar-2023 13:32:38 UTC] PHP Warning: Attempt to read property "query_vars" on array in /home/raab/public_html/wp-content/plugins/relevanssi/lib/search.php on line 581
[16-Mar-2023 13:32:38 UTC] PHP Warning: Trying to access array offset on value of type null in /home/raab/public_html/wp-content/plugins/relevanssi/lib/search.php on line 581
[16-Mar-2023 13:32:38 UTC] PHP Fatal error: Uncaught Error: Attempt to modify property "query_vars" on array in /home/raab/public_html/wp-content/plugins/relevanssi/lib/search.php:1110
Stack trace:
#0 /home/raab/public_html/wp-content/plugins/relevanssi/lib/search.php(599): relevanssi_compile_search_args(Array, '')
#1 /home/raab/public_html/wp-content/themes/raab/plugins/ajax-site-search.php(53): relevanssi_do_query(Array)
#2 /home/raab/public_html/wp-includes/class-wp-hook.php(308): ajax_site_search('')
#3 /home/raab/public_html/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters('', Array)
#4 /home/raab/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#5 /home/raab/public_html/wp-admin/admin-ajax.php(188): do_action('wp_ajax_ajax_si...')
#6 {main}
thrown in /home/raab/public_html/wp-content/plugins/relevanssi/lib/search.php on line 1110
-
This reply was modified 3 years, 2 months ago by
kspang.
The fatal error says Attempt to modify property "query_vars" on array – but the modified thing should be a WP_Query object, not an array, so something is passing Relevanssi bad data. Based on the stack trace, the problem is in /themes/raab/plugins/ajax-site-search.php. It’s calling relevanssi_do_query() wrong.
What’s in that file? In general, it’s best not to use relevanssi_do_query() at all. A cleaner method is to set the relevanssi parameter in the WP_Query arguments true and use the default WP_Query method, but if you are calling relevanssi_do_query(), check that the parameter is a WP_Query object and not an array.
Thread Starter
kspang
(@kspang)
I looked in ajax-site-search and yes there was indeed a array being passed to relevanssi_do_query(). Your suggested alternative method worked perfectly. Thank you so much! You were super helpful.