You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR integrates [Query
Monitor](https://github.com/johnbillion/query-monitor) so that it can be
used together with the SQLite Database Integration plugin, and it
extends the Query Monitor panel to include SQLite query information.
This implementation uses some tricks and workarounds to achieve this
functionality. We could improve the integration by proposing upstream
changes to the Query Monitor plugin.
#### The `wp-content/db.php` issue
The main issue to overcome was that both plugins rely on the usage of
the `wp-content/db.php` database drop-in file. To resolve this, I’ve
enabled the SQLite plugin to override the `db.php` file created by Query
Monitor while also ensuring it eagerly boots Query Monitor when needed.
The behavior depends on which plugin is activated first:
1. If the **SQLite plugin** is activated first, its `db.php` file will
never be replaced by Query Monitor. The SQLite plugin will detect when
Query Monitor is active and boot it eagerly while also storing detailed
query information for Query Monitor to consume.
2. If **Query Monitor** is activated first, the SQLite plugin will
detect that on its activation, it will replace the existing `db.php`
file, and it will retain the eager boot logic for Query Monitor. The
user will be notified about the `db.php` file replacement.
<p align="center">
<img width="600" alt="screenshot-2025-07-09-at-12 25 04"
src="https://github.com/user-attachments/assets/4fa3a947-ceb4-43f8-a50e-d28096bf5b99"
/>
</p>
#### Extended query information for Query Monitor
The SQLite plugin now stores enhanced query information for Query
Monitor when it’s active, effectively mirroring a tiny portion of the
Query Monitor code. To reduce duplication, we can propose changes to the
Query Monitor codebase that would allow this logic to be reused rather
than reimplemented.
#### Extending the Query Monitor panel
The Query Monitor panel was extended to provide information about the
executed SQLite queries for each MySQL query. This makes it easy to
inspect and debug which SQLite queries correspond to each MySQL
statement.
Currently, Query Monitor doesn’t offer a way to customize the rendered
query information. To overcome this limitation, I implemented this by
capturing the generated HTML and modifying it before it is sent to the
browser. This is another area where we could improve integration by
proposing upstream changes to the Query Monitor plugin.

#### Playground support
[Playground loads the SQLite Database Integration
differently](https://href.li/?https://github.com/WordPress/wordpress-playground/pull/1382),
without creating a `db.php` file. As a result, third-party plugins can
still inject their `db.php` drop-in. For Query Monitor, I’ve added a
simple fix. Setting the `QM_DB_SYMLINK` constant to `false` prevents it
from using the `db.php` drop-in, and the SQLite plugin will boot it as
needed.
<p><?phpesc_html_e( 'We detected that the PDO SQLite driver is missing from your server (the pdo_sqlite extension is not loaded). Please make sure that SQLite is enabled in your PHP installation before proceeding.', 'sqlite-database-integration' ); ?></p>
<p><?phpesc_html_e( 'We detected that the PDO SQLite driver is missing from your server (the pdo_sqlite extension is not loaded). Please make sure that SQLite is enabled in your PHP installation before proceeding.', 'sqlite-database-integration' ); ?></p>
<p><?phpesc_html_e( 'All checks completed successfully, your site can use an SQLite database. You can proceed with the installation.', 'sqlite-database-integration' ); ?></p>
<p><?phpesc_html_e( 'This plugin will switch to a separate database and install WordPress in it. You will need to reconfigure your site, and start with a fresh site. Disabling the plugin you will get back to your previous MySQL database, with all your previous data intact.', 'sqlite-database-integration' ); ?></p>
107
-
<p><?phpesc_html_e( 'By clicking the button below, you will be redirected to the WordPress installation screen to setup your new database', 'sqlite-database-integration' ); ?></p>
<p><?phpesc_html_e( 'All checks completed successfully, your site can use an SQLite database. You can proceed with the installation.', 'sqlite-database-integration' ); ?></p>
<p><?phpesc_html_e( 'This plugin will switch to a separate database and install WordPress in it. You will need to reconfigure your site, and start with a fresh site. Disabling the plugin you will get back to your previous MySQL database, with all your previous data intact.', 'sqlite-database-integration' ); ?></p>
<?phpesc_html_e( 'To enable SQLite support, this file will need to be replaced.', 'sqlite-database-integration' ); ?>
133
+
<?phpesc_html_e( 'The Query Monitor plugin will continue to function correctly after the change. You can safely proceed with the installation.', 'sqlite-database-integration' ); ?>
134
+
</p>
110
135
<?phpendif; ?>
136
+
137
+
<p><?phpesc_html_e( 'By clicking the button below, you will be redirected to the WordPress installation screen to setup your new database', 'sqlite-database-integration' ); ?></p>
0 commit comments