{"id":16018195,"date":"2022-09-16T21:48:33","date_gmt":"2022-09-16T21:48:33","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/fatal-errors-with-php-8-hyperdb\/"},"modified":"2022-09-16T21:48:33","modified_gmt":"2022-09-16T21:48:33","slug":"fatal-errors-with-php-8-hyperdb","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/fatal-errors-with-php-8-hyperdb\/","title":{"rendered":"Fatal errors with PHP 8 + HyperDB"},"content":{"rendered":"<p>Hello,<\/p>\n<p>The Events Calendar triggers a fatal error when using HyperDB (https:\/\/github.com\/Automattic\/HyperDB) and PHP 8:<\/p>\n<pre><code>Fatal error: Uncaught Error: mysqli_result object is already closed in \/var\/www\/wp-content\/db.php on line 1437\n\nCall stack:\n\n    mysqli_num_fields()\n    wp-content\/db.php:1437\n\n    hyperdb::ex_mysql_num_fields()\n    wp-content\/db.php:973\n\n    hyperdb::query()\n    wp-includes\/wp-db.php:2722\n\n    wpdb::get_var()\n    wp-includes\/class-wp-query.php:3381\n\n    WP_Query::set_found_posts()\n    wp-includes\/class-wp-query.php:3065\n\n    WP_Query::get_posts()\n    wp-content\/plugins\/the-events-calendar\/common\/src\/Tribe\/Repository.php:656\n\n    Tribe__Repository::found()\n    wp-content\/plugins\/the-events-calendar\/src\/Tribe\/Views\/V2\/View.php:2433\n\n    Tribe\\E\\V\\V\\View::upcoming_events_count()\n    wp-content\/plugins\/the-events-calendar\/src\/Tribe\/Views\/V2\/View.php:1907\n\n    Tribe\\E\\V\\V\\View::setup_messages()\n    wp-content\/plugins\/the-events-calendar\/src\/Tribe\/Views\/V2\/View.php:1491\n\n    Tribe\\E\\V\\V\\View::setup_template_vars()\n    wp-content\/plugins\/the-events-calendar\/src\/Tribe\/Views\/V2\/Views\/List_View.php:265\n\n    Tribe\\E\\V\\V\\V\\List_View::setup_template_vars()\n    wp-content\/plugins\/the-events-calendar\/src\/Tribe\/Views\/V2\/View.php:646\n\n    Tribe\\E\\V\\V\\View::get_html()\n    wp-content\/plugins\/the-events-calendar\/src\/Tribe\/Views\/V2\/Template_Bootstrap.php:262\n\n    Tribe\\E\\V\\V\\Template_Bootstrap::get_view_html()\n    wp-content\/plugins\/the-events-calendar\/src\/views\/v2\/default-template.php:19\n\n    include()\n    wp-includes\/template-loader.php:106\n\n    require_once()\n    wp-blog-header.php:19\n\n    require()\n    index.php:17<\/code><\/pre>\n<p>Here are the steps to reproduce the issue:<\/p>\n<ol>\n<li>Install WordPress v6.0.1<\/li>\n<li>Install <a href=\"https:\/\/wordpress.org\/plugins\/hyperdb\/\" rel=\"noopener\" target=\"_blank\">HyperDB<\/a> v1.8, using the default config (just copy <code>db.php<\/code> and <code>db-config.php<\/code> as-is right from the repo)<\/li>\n<li>Ensure the site is on PHP 7 (if you try to install the plugin on PHP 8 with HyperDB, it fatals and doesn&#8217;t install)<\/li>\n<li>Install and activate The Events Calendar v6.0.0.1<\/li>\n<li>Switch the test site to PHP 8<\/li>\n<li>Add and publish a test event: WP Admin \u2192 Events \u2192 Add New<\/li>\n<li>Visit the Events archive page (WP Admin \u2192 Events (in admin bar) \u2192 View Calendar, or by appending ?post_type=tribe_events to your test site URL)<\/li>\n<li>Observe the fatal error triggered<\/li>\n<\/ol>\n<p>The issue appears to be with how the plugin is filtering <code>posts_pre_query<\/code>, as when I comment out the following line the fatals go away:<\/p>\n<p>https:\/\/plugins.trac.wordpress.org\/browser\/the-events-calendar\/tags\/6.0.0.1\/src\/Events\/Custom_Tables\/V1\/WP_Query\/Modifiers\/Events_Only_Modifier.php#L47<\/p>\n","protected":false},"template":"","class_list":["post-16018195","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/16018195","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/16018195\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=16018195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}