Skip to content

@@TX_ISOLATION query fails silently on MySQL 8.0+ #1370

@zhyian

Description

@zhyian

Bug Report

When visiting the Matomo system report page (wp-admin/admin.php?page=matomo-systemreport) on a WordPress site running MySQL 8.0+, the following error is logged:

Unknown system variable 'TX_ISOLATION'

The error originates from WpMatomo/Db/WordPress.php at line 440, where wpdb::get_var() executes:

SELECT @@TX_ISOLATION

The @@TX_ISOLATION system variable was deprecated in MySQL 5.7.20 and removed in MySQL 8.0. The correct variable since MySQL 5.7.20 is @@transaction_isolation.

Root Cause

The WordPress DB adapter's fetchOne() uses wpdb::get_var() internally, which does not throw on query failure — it logs the error silently and returns null, which is then converted to false:

// WpMatomo/Db/WordPress.php:440
public function fetchOne($sql, $bind = array()) {
    global $wpdb;
    $prepare = $this->prepareWp($sql, $bind);

    $this->before_execute_query($wpdb, $sql);
    $value = $wpdb->get_var($prepare); // fails silently on MySQL 8.0+, logs error
    $this->after_execute_query($wpdb, $sql);

    if ($value === null) {
        return false; // no exception thrown
    }

    return $value;
}

Any caller that queries @@TX_ISOLATION and relies on an exception-based fallback to @@transaction_isolation will never reach that fallback when going through this adapter — the error is swallowed by wpdb and false is returned instead.

Environment

Plugin Matomo Analytics 5.7.1
WordPress 5.9.1 Multisite
PHP 8.4.18
MySQL 8.4.7
Hosting WP Engine
Affected page wp-admin/admin.php?page=matomo-systemreport

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions