Skip to content

Commit 3a9b4b8

Browse files
committed
Check if Query Monitor is installed before querying for if it's active
1 parent 0bc3d0f commit 3a9b4b8

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
@@ -95,6 +95,20 @@ function register_sqlite_enhancements_for_query_monitor() {
9595
return;
9696
}
9797

98+
// Check if Query Monitor is installed.
99+
if ( defined( 'WP_PLUGIN_DIR' ) ) {
100+
$plugins_dir = WP_PLUGIN_DIR;
101+
} else {
102+
$plugins_dir = WP_CONTENT_DIR . '/plugins';
103+
}
104+
105+
$qm_dir = "{$plugins_dir}/query-monitor";
106+
$qm_php = "{$qm_dir}/classes/PHP.php";
107+
108+
if ( ! is_readable( $qm_php ) ) {
109+
return;
110+
}
111+
98112
// Check if Query Monitor is active.
99113
if ( null === $wpdb->options ) {
100114
global $table_prefix;
@@ -124,20 +138,7 @@ function register_sqlite_enhancements_for_query_monitor() {
124138
return;
125139
}
126140

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

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

0 commit comments

Comments
 (0)