Skip to content

Detect and surface database driver/server mismatch - #4682

Merged
imorland merged 1 commit into
2.xfrom
im/db-driver-mismatch-warning
Jun 2, 2026
Merged

Detect and surface database driver/server mismatch#4682
imorland merged 1 commit into
2.xfrom
im/db-driver-mismatch-warning

Conversation

@imorland

@imorland imorland commented Jun 2, 2026

Copy link
Copy Markdown
Member

The problem

Since 2.x, Flarum treats MariaDB as a database driver distinct from MySQL. On Illuminate 13 each driver has its own connection class (MySqlConnection vs MariaDbConnection) and its own query grammar, so the two are not interchangeable.

In practice, a large number of "something isn't working" reports come down to a single misconfiguration: the user has 'driver' => 'mysql' in config.php while actually connecting to a MariaDB server (or, less commonly, the reverse). This is extremely easy to do when upgrading from 1.x or following older guides, where mysql was the only relevant option. Because the connection still succeeds, the mismatch is invisible — it only shows up later as subtle, hard-to-diagnose query bugs that look unrelated to the database config.

Today nothing tells the admin that their configured driver doesn't match the server they're actually talking to.

What this does

Detects the mismatch and makes it impossible to miss, in the two places admins already look:

  • Admin dashboard — a non-dismissible error banner (modelled on the existing debug-mode warning) that names the configured driver, the detected server, and the exact 'driver' => '…' value to set in config.php, with a link to the docs.
  • php flarum info — the database line is flagged inline, plus a trailing error explaining how to fix it (alongside the existing debug-mode notice).

How detection works

Only MySQL and MariaDB can be confused for one another, so detection is scoped to those two drivers. A new ApplicationInfoProvider::identifyDatabaseDriverMismatch() compares the configured driver against the server's reported version() string — the same MariaDB marker the installer already relies on in ConnectToDatabase. It returns the driver that should be configured, or null when everything matches. The lookup reuses the existing 24h cache layer, so there's no per-request query cost. pgsql/sqlite short-circuit and never hit the database.

Flarum 2.x treats MariaDB as a distinct driver from MySQL (separate
Illuminate connection classes and query grammars). Configuring the
'mysql' driver against a MariaDB server (or vice versa) produces subtle,
hard-to-diagnose query bugs that surface as seemingly unrelated reports.

Detect the mismatch by comparing the configured driver against the
server's reported version, and surface it both in the admin dashboard
(as an error banner) and in `php flarum info`, telling the user exactly
which driver to set in config.php.
@imorland
imorland requested a review from a team as a code owner June 2, 2026 07:03
@imorland imorland added this to the 2.0.0-rc.3 milestone Jun 2, 2026
@imorland
imorland merged commit dedbc98 into 2.x Jun 2, 2026
25 checks passed
@imorland
imorland deleted the im/db-driver-mismatch-warning branch June 2, 2026 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant