Skip to content

Commit 7cf6b93

Browse files
authored
Fix activation with Query Monitor 4.1.2 (#642)
## Summary Fixes plugin activation with **Query Monitor 4.1.2**. The SQLite integration now loads Query Monitor's new `autoload.php` so it can start recording database queries early. Older releases continue to use Composer's `vendor/autoload.php`. ## Why Query Monitor 4.1.2 removed both its bundled Composer autoloader and the `QM_PHP::vendor_nope` notice. The SQLite integration treated the missing Composer file as an incomplete install and registered the removed callback. WordPress then tried to call it when rendering the Plugins screen after activation. [Query Monitor changes](johnbillion/query-monitor@4.1.1...4.1.2) · [Failing end-to-end test on trunk](https://github.com/WordPress/sqlite-database-integration/actions/runs/45997026427) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit - **Bug Fixes** - Improved Query Monitor compatibility across installations by using an available autoloader, including support for older setups. - Avoided registering a missing-autoloader notice when its handler is unavailable. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 758da32 commit 7cf6b93

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

  • packages/plugin-sqlite-database-integration/integrations/query-monitor

‎packages/plugin-sqlite-database-integration/integrations/query-monitor/boot.php‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,18 @@ function register_sqlite_enhancements_for_query_monitor() {
153153
return;
154154
}
155155

156-
if ( ! file_exists( "{$qm_dir}/vendor/autoload.php" ) ) {
157-
add_action( 'all_admin_notices', 'QM_PHP::vendor_nope' );
156+
if ( is_readable( "{$qm_dir}/autoload.php" ) ) {
157+
require_once "{$qm_dir}/autoload.php";
158+
} elseif ( is_readable( "{$qm_dir}/vendor/autoload.php" ) ) {
159+
// Query Monitor used Composer's autoloader before 4.1.2.
160+
require_once "{$qm_dir}/vendor/autoload.php";
161+
} else {
162+
if ( is_callable( 'QM_PHP::vendor_nope' ) ) {
163+
add_action( 'all_admin_notices', 'QM_PHP::vendor_nope' );
164+
}
158165
return;
159166
}
160167

161-
require_once "{$qm_dir}/vendor/autoload.php";
162-
163168
if ( ! class_exists( 'QM_Backtrace' ) ) {
164169
return;
165170
}

0 commit comments

Comments
 (0)