Skip to content

Commit 11e51be

Browse files
committed
Check if Query Monitor is installed before querying for if it's active
1 parent f7ed7c3 commit 11e51be

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

integrations/query-monitor/boot.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,20 @@ function register_sqlite_enhancements_for_query_monitor() {
9999
return;
100100
}
101101

102+
// Check if Query Monitor is installed.
103+
if ( defined( 'WP_PLUGIN_DIR' ) ) {
104+
$plugins_dir = WP_PLUGIN_DIR;
105+
} else {
106+
$plugins_dir = WP_CONTENT_DIR . '/plugins';
107+
}
108+
109+
$qm_dir = "{$plugins_dir}/query-monitor";
110+
$qm_php = "{$qm_dir}/classes/PHP.php";
111+
112+
if ( ! is_readable( $qm_php ) ) {
113+
return;
114+
}
115+
102116
// Check if Query Monitor is active.
103117
if ( null === $wpdb->options ) {
104118
global $table_prefix;
@@ -128,20 +142,7 @@ function register_sqlite_enhancements_for_query_monitor() {
128142
return;
129143
}
130144

131-
// Determine the plugins directory.
132-
if ( defined( 'WP_PLUGIN_DIR' ) ) {
133-
$plugins_dir = WP_PLUGIN_DIR;
134-
} else {
135-
$plugins_dir = WP_CONTENT_DIR . '/plugins';
136-
}
137-
138-
// Load Query Monitor (as per the original "db.php" file).
139-
$qm_dir = "{$plugins_dir}/query-monitor";
140-
$qm_php = "{$qm_dir}/classes/PHP.php";
141-
142-
if ( ! is_readable( $qm_php ) ) {
143-
return;
144-
}
145+
// Load Query Monitor eagerly (as per the original "db.php" file).
145146
require_once $qm_php;
146147

147148
if ( ! QM_PHP::version_met() ) {

0 commit comments

Comments
 (0)