Skip to content

Commit 918489d

Browse files
authored
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).
1 parent 37497be commit 918489d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

integrations/query-monitor/boot.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@
3939
}
4040

4141
if ( 'cli' === php_sapi_name() && ! defined( 'QM_TESTS' ) ) {
42-
return;
42+
if ( ! defined( 'QM_RUN_IN_CLI' ) || ! QM_RUN_IN_CLI ) {
43+
return;
44+
}
4345
}
4446

4547
if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
@@ -56,6 +58,10 @@
5658
}
5759
}
5860

61+
if ( ! isset( $wpdb ) ) {
62+
return;
63+
}
64+
5965
// 2. Check if Query Monitor is active.
6066
if ( null === $wpdb->options ) {
6167
global $table_prefix;

0 commit comments

Comments
 (0)