Hello flithor,
Thank you for reporting this error. An update was released on July 5, 2023 (Question2Answer v1.8.7) that officially fixed this issue. If you are still facing this problem, updating your Question2Answer website is the simplest solution. What follows is a brief explanation on when this problem arose and how to fix it.
Q2A installation
Question2Answer has a mechanism for installing/updating/fixing its own database when needed; namely, when a database error arises, it runs a set of checks to determine whether one of those operations is needed.
When requesting a regular page on your website, like the homepage, the following lines at qa-include/qa-page.php are executed:
qa_db_connect('qa_page_db_fail_handler');
qa_initialize_postdb_plugins();
The first line is for connecting to the database and setting an error handling routine named qa_page_db_fail_handler; the second line loads Question2Answer plugins, which in turn loads the website options (settings from Q2A and plugins) from the database.
This error occurs because the table containing website options ('q2a_db.qa_options') doesn't exist in a new Q2A installation. However, the error handler catches this error, confirms the database is actually empty, and finally proceeds with the installation process.
But if everything is functioning just alright, why does it stop working? The answer is in the latest PHP 8 updates which affects how Question2Answer get data (query) from database.
PHP 8 Updates
The function qa_db_query_execute runs database queries via $db, which is an instance of mysqli, in this manner:
$result = $db->query($query);
But, according to Salman's post, the MySQLi extention defaults to throwing exceptions, instead of just keeping errors silent, as of PHP 8.1. This new default behavior makes Q2A error handling method go off the normal course and throw a PHP exception.
Solution
pupi1985' answer and Salman's post agree on handling this situation by invoking mysqli_report(MYSQLI_REPORT_OFF) before making the first MySQLi connection.
Tidbits
There are other errors or warnings related to PHP 8 updates; for example, just after fixing this issue, the following deprecation notice:
Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated
was thrown after continuing with the installation process. These errors disappear after updating to Question2Answer v1.8.8.
I hope this clarification is helpful to you and the community. If you have any question about this subject, please leave a comment below or update your question with more details.
Take care, bye!