Title: Fatal errors with PHP 8 + HyperDB
Last modified: September 16, 2022

---

# Fatal errors with PHP 8 + HyperDB

 *  Resolved [Raam Dev](https://wordpress.org/support/users/raamdev/)
 * (@raamdev)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/fatal-errors-with-php-8-hyperdb/)
 * Hello,
 * The Events Calendar triggers a fatal error when using HyperDB ([https://github.com/Automattic/HyperDB](https://github.com/Automattic/HyperDB))
   and PHP 8:
 *     ```
       Fatal error: Uncaught Error: mysqli_result object is already closed in /var/www/wp-content/db.php on line 1437
   
       Call stack:
   
           mysqli_num_fields()
           wp-content/db.php:1437
   
           hyperdb::ex_mysql_num_fields()
           wp-content/db.php:973
   
           hyperdb::query()
           wp-includes/wp-db.php:2722
   
           wpdb::get_var()
           wp-includes/class-wp-query.php:3381
   
           WP_Query::set_found_posts()
           wp-includes/class-wp-query.php:3065
   
           WP_Query::get_posts()
           wp-content/plugins/the-events-calendar/common/src/Tribe/Repository.php:656
   
           Tribe__Repository::found()
           wp-content/plugins/the-events-calendar/src/Tribe/Views/V2/View.php:2433
   
           Tribe\E\V\V\View::upcoming_events_count()
           wp-content/plugins/the-events-calendar/src/Tribe/Views/V2/View.php:1907
   
           Tribe\E\V\V\View::setup_messages()
           wp-content/plugins/the-events-calendar/src/Tribe/Views/V2/View.php:1491
   
           Tribe\E\V\V\View::setup_template_vars()
           wp-content/plugins/the-events-calendar/src/Tribe/Views/V2/Views/List_View.php:265
   
           Tribe\E\V\V\V\List_View::setup_template_vars()
           wp-content/plugins/the-events-calendar/src/Tribe/Views/V2/View.php:646
   
           Tribe\E\V\V\View::get_html()
           wp-content/plugins/the-events-calendar/src/Tribe/Views/V2/Template_Bootstrap.php:262
   
           Tribe\E\V\V\Template_Bootstrap::get_view_html()
           wp-content/plugins/the-events-calendar/src/views/v2/default-template.php:19
   
           include()
           wp-includes/template-loader.php:106
   
           require_once()
           wp-blog-header.php:19
   
           require()
           index.php:17
       ```
   
 * Here are the steps to reproduce the issue:
    1. Install WordPress v6.0.1
    2. Install [HyperDB](https://wordpress.org/plugins/hyperdb/) v1.8, using the default
       config (just copy `db.php` and `db-config.php` as-is right from the repo)
    3. Ensure the site is on PHP 7 (if you try to install the plugin on PHP 8 with 
       HyperDB, it fatals and doesn’t install)
    4. Install and activate The Events Calendar v6.0.0.1
    5. Switch the test site to PHP 8
    6. Add and publish a test event: WP Admin → Events → Add New
    7. Visit the Events archive page (WP Admin → Events (in admin bar) → View Calendar,
       or by appending ?post_type=tribe_events to your test site URL)
    8. Observe the fatal error triggered
 * The issue appears to be with how the plugin is filtering `posts_pre_query`, as
   when I comment out the following line the fatals go away:
 * [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](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)

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

 *  Plugin Support [WilloftheD](https://wordpress.org/support/users/abzlevelup/)
 * (@abzlevelup)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/fatal-errors-with-php-8-hyperdb/#post-16026010)
 * Hi [@raamdev](https://wordpress.org/support/users/raamdev/), sorry to hear about
   this, and appreciate you taking the time to share the findings and steps to reproduce
   here. This is really helpful for us. I’d definitely share this with our team/
   devs.
 * Quick question were you able to use the plugin properly after commenting those
   lines of code? And continue with the migration to v6.0?
 * Looking forward to hearing from you.
 * Best,
    Abz
 *  Thread Starter [Raam Dev](https://wordpress.org/support/users/raamdev/)
 * (@raamdev)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/fatal-errors-with-php-8-hyperdb/#post-16032583)
 * Hi [@abzlevelup](https://wordpress.org/support/users/abzlevelup/),
 * > Quick question were you able to use the plugin properly after commenting those
   > lines of code? And continue with the migration to v6.0?
 * The plugin appeared to work normally with that line commented out, however I 
   did not do any extensive testing as I’m not familiar with all of the plugin’s
   features. Also, there was no migration to v6.0 involved—I was testing v6.0 and
   did not have any previous versions installed.
 *  Plugin Support [WilloftheD](https://wordpress.org/support/users/abzlevelup/)
 * (@abzlevelup)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/fatal-errors-with-php-8-hyperdb/#post-16032746)
 * Hi [@raamdev](https://wordpress.org/support/users/raamdev/), thanks for confirming
   this and for testing it out. Appreciate you bringing this to our attention in
   regards to the **HyperDB** compatibility issue and the findings. I already shared
   this with our team and making sure we take note of this. This is helpful for 
   us.
 * Please do not hesitate to bump a new topic on our way, this would help us track
   topics/issues more efficiently. We’d be glad to help you out.
 * Have a great day.
 * Best,
    Abz
 *  Plugin Support [Erica](https://wordpress.org/support/users/eeide/)
 * (@eeide)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/fatal-errors-with-php-8-hyperdb/#post-16035804)
 * Hi [@raamdev](https://wordpress.org/support/users/raamdev/)!
 * We wanted to let you know that with our latest release of The Events Calendar
   version 6.0.1, we resolved the issue that you were experiencing. Be sure to review
   our full [Release Notes](https://theeventscalendar.com/release-notes/the-events-calendar/the-events-calendar-6-0-1/)
   for more details, and update the plugin at your earliest convenience.
 * As always, we suggest [testing updates on a staging site first](https://theeventscalendar.com/knowledgebase/k/creating-and-using-a-wordpress-staging-site/),
   and having a recent backup, but it should all be smooth sailing. If you implemented
   any workarounds, you may remove them after updating.
 * If you still have issues after updating to the latest release, please let us 
   know.
 * Have a great rest of your day!
 * Thanks,
    Erica
 *  Thread Starter [Raam Dev](https://wordpress.org/support/users/raamdev/)
 * (@raamdev)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/fatal-errors-with-php-8-hyperdb/#post-16045324)
 * Hi [@eeide](https://wordpress.org/support/users/eeide/),
 * Unfortunately v6.0.1 did not fix the issue with PHP 8 + HyperDB. I’m still getting
   the same fatal error when visiting the events archive page.
 *  [Chetan Satasiya](https://wordpress.org/support/users/ketuchetan/)
 * (@ketuchetan)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/fatal-errors-with-php-8-hyperdb/#post-16046001)
 * [@raamdev](https://wordpress.org/support/users/raamdev/) Yes, I agreed with you
   the latest update is not fixing the issue with the HyperDB as I am getting the
   same errors on my PHP8.0 site.
 * [@eeide](https://wordpress.org/support/users/eeide/) [@abzlevelup](https://wordpress.org/support/users/abzlevelup/)
   here is the log
 * > `<b>Fatal error</b>: Uncaught Error: mysqli_result object is already closed
   > in /var/www/wp-content/db.php:1437
   >  Stack trace: #0 /var/www/wp-content/db.
   > php(1437): mysqli_num_fields(Object(mysqli_result)) #1 /var/www/wp-content/
   > db.php(973): hyperdb->ex_mysql_num_fields(Object(mysqli_result)) #2 /var/www/
   > wp-includes/wp-db.php(2722): hyperdb->query(‘SELECT FOUND_RO…’) #3 /var/www/
   > wp-includes/class-wp-query.php(3381): wpdb->get_var(‘SELECT FOUND_RO…’) #4 /
   > var/www/wp-includes/class-wp-query.php(3065): WP_Query->set_found_posts(Array,‘
   > LIMIT 0, 31’) #5 /var/www/wp-content/plugins/the-events-calendar/common/src/
   > Tribe/Repository.php(571): WP_Query->get_posts() #6 /var/www/wp-content/plugins/
   > the-events-calendar/common/src/Tribe/Repository/Decorator.php(204): Tribe__Repository-
   > >count() #7 /var/www/wp-content/plugins/events-calendar-pro/src/Tribe/Views/
   > V2/Views/Photo_View.php(116): Tribe__Repository__Decorator->count() #8 /var/
   > www/wp-content/plugins/events-calendar-pro/src/Tribe/Views/V2/Views/Photo_View.
   > php(58): Tribe\Events\Pro\Views\V2\Views\Photo_View->get_past_url(false) #9/
   > var/www/wp-content/plugins/the-events-calendar/src/Tribe/Views/V2/View.php(
   > 1537): Tribe\Events\Pro\Views\V2\Views\Photo_View->prev_url(false) #10 /var/
   > www/wp-content/plugins/events-calendar-pro/src/Tribe/Views/V2/Views/Photo_View.
   > php(253): Tribe\Events\Views\V2\View->setup_template_vars() #11 /var/www/wp-
   > content/plugins/the-events-calendar/src/Tribe/Views/V2/View.php(646): Tribe\
   > Events\Pro\Views\V2\Views\Photo_View->setup_template_vars() #12 /var/www/wp-
   > content/plugins/events-calendar-pro/src/Tribe/Views/V2/Shortcodes/Tribe_Events.
   > php(727): Tribe\Events\Views\V2\View->get_html() #13 /var/www/wp-content/plugins/
   > the-events-calendar/common/src/Tribe/Shortcode/Manager.php(116): Tribe\Events\
   > Pro\Views\V2\Shortcodes\Tribe_Events->get_html() #14 /var/www/wp-includes/shortcodes.
   > php(356): Tribe\Shortcode\Manager->render_shortcode(Array, ”, ‘tribe_events’)#
   > 15 [internal function]: do_shortcode_tag(Array)`
 *  [Chetan Satasiya](https://wordpress.org/support/users/ketuchetan/)
 * (@ketuchetan)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/fatal-errors-with-php-8-hyperdb/#post-16051687)
 * Hey [@eeide](https://wordpress.org/support/users/eeide/) [@abzlevelup](https://wordpress.org/support/users/abzlevelup/)
 * It would be a good if you guys can provide any update on this.
 * Thanks
 *  Plugin Contributor [András Guseo](https://wordpress.org/support/users/aguseo/)
 * (@aguseo)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/fatal-errors-with-php-8-hyperdb/#post-16052791)
 * Hi [@ketuchetan](https://wordpress.org/support/users/ketuchetan/) [@raamdev](https://wordpress.org/support/users/raamdev/)
 * Sorry to hear that didn’t help. It was flagged by others as well. We will be 
   looking into this and we will try and hopefully manage to offer a fix in our 
   next release around mid-October. We ask for your kind patience as we are working
   through the bugs.
 * Thanks,
    Andras ________________________ Internal Bug Ticket Reference: ECP-1360
 *  [Nick the Geek](https://wordpress.org/support/users/nick_thegeek/)
 * (@nick_thegeek)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/fatal-errors-with-php-8-hyperdb/#post-16133391)
 * Hey all,
 * I ran into this with a client after we updated to PHP8 on WordPress VIP. Unfortunately
   this is going to be a bigger issue for clients on that platform as they are enforcing
   PHP8 starting next month.
 * I commented out the filter and it is “working” again but I’m not sure what else
   is affected by this.
 * I tested by updating to v6.0.2 before commenting the code, but that did not resolve
   the issue.
 * Looking forward to a solution.
 * thanks!
 *  Plugin Support [WilloftheD](https://wordpress.org/support/users/abzlevelup/)
 * (@abzlevelup)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/fatal-errors-with-php-8-hyperdb/#post-16134171)
 * Hi [@nick_thegeek](https://wordpress.org/support/users/nick_thegeek/), sorry 
   to hear about this, and thanks for sharing more information here. We already 
   created an internal bug ticket for this, and I have added your case to it. Thanks
   for all the details, I will definitely pass it along to our devs.
 * I am unable to provide an exact date or time estimate for when this bug will 
   be fixed, but you’ll be notified when there are any updates.
 * If you do have other concerns or issues you need help with, please create another
   ticket, as it helps us track different issues.
 * Again, thank you for your patience. Hang in there.
 * Thanks,
    Abz ________________________ Internal Bug Ticket Reference: ECP-1360
 *  [Nick the Geek](https://wordpress.org/support/users/nick_thegeek/)
 * (@nick_thegeek)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/fatal-errors-with-php-8-hyperdb/#post-16139484)
 * [@abzlevelup](https://wordpress.org/support/users/abzlevelup/), I appreciate 
   that. I’m wondering if it might be possible to get a filter that allows disabling
   this filter or update the add_filter to use a static callback in the interim.
   The issue is that the temporary solution of commenting out this line of code 
   means we have to apply it every time the plugin is updated. If I could just `
   remove_filter()` or other wise disable this line of code from outside the plugin
   then we would be able to apply updates and just wait to see if it is fixed.
 *  Plugin Support [WilloftheD](https://wordpress.org/support/users/abzlevelup/)
 * (@abzlevelup)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/fatal-errors-with-php-8-hyperdb/#post-16159674)
 * Hi [@nick_thegeek](https://wordpress.org/support/users/nick_thegeek/), sorry 
   to hear about this, and apologies for the delay here. We do not have a workaround
   function/filter for this one.
 * Appreciate your patience here. Rest assured we’d be notifying you whenever there
   are updates in this thread.
 * Thanks,
    Andras ________________________ Internal Bug Ticket Reference: ECP-1360
 *  [Chetan Satasiya](https://wordpress.org/support/users/ketuchetan/)
 * (@ketuchetan)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/fatal-errors-with-php-8-hyperdb/#post-16185638)
 * Hey [@abzlevelup](https://wordpress.org/support/users/abzlevelup/)
 * It would be good if you guys can provide any update on this. As our hosting will
   update to PHP8 before 15th Nov 2022 as we need this before that upgradation in
   hosting.
 * Looking forward to hearing from you.
 * Thanks
 *  Plugin Support [Gladys](https://wordpress.org/support/users/greventscalendar/)
 * (@greventscalendar)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/fatal-errors-with-php-8-hyperdb/#post-16201558)
 * Hi there,
 * With our latest release of [The Events Calendar 6.0.4](https://theeventscalendar.com/release-notes/the-events-calendar/the-events-calendar-6-0-4/),
   we resolved an issue causing error messages a conflict with The Events Calendar,
   PHP 8, and HyperDB. Please be sure to review our full Release Notes for more 
   details and update your plugin whenever you get a chance.
 * As always, we suggest testing updates on a staging site first and having a recent
   backup, but it should all be smooth sailing. If you implemented any workarounds,
   you can remove them after updating the plugins.
 * If you still have issues after updating to the latest releases, please open a
   new support thread and include any specific details and screenshots if possible.
 * Have a great day,
    Gladys
    -  This reply was modified 3 years, 4 months ago by [Gladys](https://wordpress.org/support/users/greventscalendar/).
 *  Plugin Support [WilloftheD](https://wordpress.org/support/users/abzlevelup/)
 * (@abzlevelup)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/fatal-errors-with-php-8-hyperdb/page/2/#post-16250143)
 * Hi [@raamdev](https://wordpress.org/support/users/raamdev/),
 * We haven’t heard from you in a while, so I’m going to mark this as resolved. 
   Feel free to start a new thread if you have any more questions.

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

The topic ‘Fatal errors with PHP 8 + HyperDB’ is closed to new replies.

 * ![](https://ps.w.org/the-events-calendar/assets/icon-256x256.gif?rev=2516440)
 * [The Events Calendar](https://wordpress.org/plugins/the-events-calendar/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/the-events-calendar/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/the-events-calendar/)
 * [Active Topics](https://wordpress.org/support/plugin/the-events-calendar/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/the-events-calendar/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/the-events-calendar/reviews/)

 * 16 replies
 * 7 participants
 * Last reply from: [WilloftheD](https://wordpress.org/support/users/abzlevelup/)
 * Last activity: [3 years, 4 months ago](https://wordpress.org/support/topic/fatal-errors-with-php-8-hyperdb/page/2/#post-16250143)
 * Status: resolved