Title: PHP 8.1 Compatibility
Last modified: March 15, 2023

---

# PHP 8.1 Compatibility

 *  Resolved [kspang](https://wordpress.org/support/users/kspang/)
 * (@kspang)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/php-8-1-compatibility-21/)
 * Hello,
 * I migrated a website to PHP version 8.1. After the update the search plugin Relevanssi
   stopped working. I was curious if this is a PHP8 compatibility issue or if it’s
   something on my end. I didn’t see any mention of PHP8 in the changelog. Also 
   the errors are thrown outside of the theme. If it is not compatible, will it 
   be updated soon? I wanted to ask before I go in and update it myself.
 * Thank you to anyone who reads this,
 * Keith

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/php-8-1-compatibility-21/#post-16564326)
 * 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](https://wordpress.org/support/users/kspang/)
 * (@kspang)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/php-8-1-compatibility-21/#post-16566124)
 * 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!
 *     ```wp-block-code
       [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
       ```
   
 *     ```wp-block-code
       [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
       ```
   
 *     ```wp-block-code
       [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
       ```
   
 *     ```wp-block-code
       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, 3 months ago by [kspang](https://wordpress.org/support/users/kspang/).
 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/php-8-1-compatibility-21/#post-16566754)
 * 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](https://wordpress.org/support/users/kspang/)
 * (@kspang)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/php-8-1-compatibility-21/#post-16567297)
 * 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.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘PHP 8.1 Compatibility’ is closed to new replies.

 * ![](https://ps.w.org/relevanssi/assets/icon-256x256.png?rev=3529670)
 * [Relevanssi - A Better Search](https://wordpress.org/plugins/relevanssi/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/relevanssi/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/relevanssi/)
 * [Active Topics](https://wordpress.org/support/plugin/relevanssi/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/relevanssi/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/relevanssi/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [kspang](https://wordpress.org/support/users/kspang/)
 * Last activity: [3 years, 3 months ago](https://wordpress.org/support/topic/php-8-1-compatibility-21/#post-16567297)
 * Status: resolved