From 918489d27270be27259de6839580c0460ad475db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Zieli=C5=84ski?= Date: Thu, 24 Jul 2025 18:13:18 +0200 Subject: [PATCH] Query monitor: WordPress Playground compatibility Accounts for the WordPress Playground runtime, where the sapi name is `cli` and the `$wpdb` variable [may not be available](https://github.com/WordPress/wordpress-playground/blob/c27a05386ce480c19a67be316d9bc093ffeec256/packages/playground/wordpress/src/index.ts#L391-L462). --- integrations/query-monitor/boot.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/integrations/query-monitor/boot.php b/integrations/query-monitor/boot.php index 928c3413..7e8ae300 100644 --- a/integrations/query-monitor/boot.php +++ b/integrations/query-monitor/boot.php @@ -39,7 +39,9 @@ } if ( 'cli' === php_sapi_name() && ! defined( 'QM_TESTS' ) ) { - return; + if ( ! defined( 'QM_RUN_IN_CLI' ) || ! QM_RUN_IN_CLI ) { + return; + } } if ( defined( 'DOING_CRON' ) && DOING_CRON ) { @@ -56,6 +58,10 @@ } } +if ( ! isset( $wpdb ) ) { + return; +} + // 2. Check if Query Monitor is active. if ( null === $wpdb->options ) { global $table_prefix;