Skip to content

Commit

Permalink
Revert "update query monitor (#5028)" (#5042)
Browse files Browse the repository at this point in the history
This reverts commit d527d41.
  • Loading branch information
rebeccahum committed Nov 22, 2023
1 parent b9b25a7 commit 9bb1580
Show file tree
Hide file tree
Showing 66 changed files with 688 additions and 1,530 deletions.
26 changes: 10 additions & 16 deletions query-monitor/assets/query-monitor.css
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@
#wpadminbar .qm-alert {
background-color: #f60;
}
#wpadminbar #wp-admin-bar-query-monitor-doing_it_wrong a,
#wpadminbar #wp-admin-bar-query-monitor-stricts a,
#wpadminbar #wp-admin-bar-query-monitor-deprecateds a,
#wpadminbar #wp-admin-bar-query-monitor-notices a,
Expand All @@ -176,9 +175,7 @@
#wpadminbar .qm-notice {
background-color: #740;
}
#wpadminbar #wp-admin-bar-query-monitor-doing_it_wrong a:focus, #wpadminbar #wp-admin-bar-query-monitor-doing_it_wrong a:hover,
#wpadminbar #wp-admin-bar-query-monitor-stricts a:focus,
#wpadminbar #wp-admin-bar-query-monitor-stricts a:hover,
#wpadminbar #wp-admin-bar-query-monitor-stricts a:focus, #wpadminbar #wp-admin-bar-query-monitor-stricts a:hover,
#wpadminbar #wp-admin-bar-query-monitor-deprecateds a:focus,
#wpadminbar #wp-admin-bar-query-monitor-deprecateds a:hover,
#wpadminbar #wp-admin-bar-query-monitor-notices a:focus,
Expand Down Expand Up @@ -244,7 +241,6 @@ body.admin-color-light #wp-admin-bar-query-monitor:not(.qm-all-clear):not(:hover
#wp-admin-bar-query-monitor-default .qm-alert a,
#wp-admin-bar-query-monitor-default .qm-error a,
#wp-admin-bar-query-monitor-default .qm-warning a,
#wp-admin-bar-query-monitor-doing_it_wrong a,
#wp-admin-bar-query-monitor-deprecateds a,
#wp-admin-bar-query-monitor-stricts a,
#wp-admin-bar-query-monitor-notices a,
Expand Down Expand Up @@ -442,8 +438,8 @@ body.admin-color-light #wp-admin-bar-query-monitor:not(.qm-all-clear):not(:hover
height: 27px;
}
#query-monitor-main.qm-show {
height: 60%;
width: 60%;
height: 40%;
width: 40%;
}
#query-monitor-main:not(.qm-show-right) {
width: 100% !important;
Expand Down Expand Up @@ -606,7 +602,7 @@ body.admin-color-light #wp-admin-bar-query-monitor:not(.qm-all-clear):not(:hover
color: var(--qm-panel-menu-fg) !important;
cursor: pointer !important;
display: block !important;
padding: 7px 32px 7px 10px !important;
padding: 6px 32px 6px 10px !important;
position: relative !important;
text-decoration: none !important;
width: 100% !important;
Expand Down Expand Up @@ -733,7 +729,7 @@ body.admin-color-light #wp-admin-bar-query-monitor:not(.qm-all-clear):not(:hover
#query-monitor-main .qm tfoot th,
#query-monitor-main .qm tfoot td {
border: 1px solid var(--qm-cell-border) !important;
padding: 6px 6px 5px 6px !important;
padding: 5px 5px 4px 5px !important;
vertical-align: top !important;
}
#query-monitor-main .qm tbody th,
Expand All @@ -746,7 +742,7 @@ body.admin-color-light #wp-admin-bar-query-monitor:not(.qm-all-clear):not(:hover
border: 1px solid var(--qm-cell-border) !important;
border-top: none !important;
box-shadow: 0 1px 0 var(--qm-cell-border) !important;
padding: 5px 5px 5px 6px !important;
padding: 5px !important;
position: -webkit-sticky !important;
position: sticky !important;
top: 0 !important;
Expand Down Expand Up @@ -789,7 +785,7 @@ body.admin-color-light #wp-admin-bar-query-monitor:not(.qm-all-clear):not(:hover
#query-monitor-main .qm td.qm-num {
font-family: Menlo, Monaco, Consolas, monospace !important;
font-size: 11px !important;
line-height: 20px !important;
line-height: 19px !important;
}
#query-monitor-main .qm td.qm-row-sql {
min-width: 25em !important;
Expand All @@ -809,7 +805,7 @@ body.admin-color-light #wp-admin-bar-query-monitor:not(.qm-all-clear):not(:hover
min-width: 15em !important;
}
#query-monitor-main .qm td.qm-has-toggle {
padding-right: 28px !important;
padding-right: 24px !important;
position: relative !important;
}
#query-monitor-main .qm td.qm-has-toggle:not(.qm-toggled-on) .qm-supplemental {
Expand Down Expand Up @@ -901,7 +897,6 @@ body.admin-color-light #wp-admin-bar-query-monitor:not(.qm-all-clear):not(:hover
#query-monitor-main .qm li {
display: list-item !important;
list-style: none !important;
line-height: 20px !important;
}
#query-monitor-main .qm li::before {
content: "" !important;
Expand All @@ -910,7 +905,7 @@ body.admin-color-light #wp-admin-bar-query-monitor:not(.qm-all-clear):not(:hover
#query-monitor-main .qm pre {
font-family: Menlo, Monaco, Consolas, monospace !important;
font-size: 11px !important;
line-height: 20px !important;
line-height: 19px !important;
}
#query-monitor-main .qm pre {
background: transparent !important;
Expand Down Expand Up @@ -1264,8 +1259,7 @@ body.admin-color-light #wp-admin-bar-query-monitor:not(.qm-all-clear):not(:hover
#query-monitor-main .qm-hide-name,
#query-monitor-main .qm-hide-type,
#query-monitor-main .qm-hide-caller,
#query-monitor-main .qm-hide-component,
#query-monitor-main .qm-hide-host {
#query-monitor-main .qm-hide-component {
display: none !important;
}
#query-monitor-main .qm thead th.qm-sortable-column {
Expand Down
26 changes: 4 additions & 22 deletions query-monitor/assets/query-monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,38 +253,20 @@ if ( window.jQuery ) {
}

var matches = tr.filter(':visible');
var filtered_count = 0;
var total_count = 0;
matches.each(function(i){
var row_time = $(this).attr('data-qm-time');
if ( row_time ) {
time += parseFloat( row_time );
}

var row_count = $(this).attr('data-qm-count');
if ( row_count ) {
filtered_count += parseFloat( row_count );
} else {
filtered_count++;
}
});
if ( time ) {
time = QM_i18n.number_format( time, 4 );
}

tr.each(function(i){
var row_count = $(this).attr('data-qm-count');
if ( row_count ) {
total_count += parseFloat( row_count );
} else {
total_count++;
}
});

if ( table.find('.qm-filtered').length ) {
var count = filtered_count + ' / ' + total_count;
var count = matches.length + ' / ' + tr.length;
} else {
var count = filtered_count;
var count = matches.length;
}

table.find('.qm-items-number').text(count);
Expand Down Expand Up @@ -328,7 +310,7 @@ if ( window.jQuery ) {
var toggle = $(this).closest('td').find('.qm-toggled');
if ( currentState === 'true' ) {
if ( toggle.length ) {
toggle.slideToggle(150,function(){
toggle.slideToggle(200,function(){
el.closest('td').removeClass('qm-toggled-on');
el.text(el.attr('data-on'));
});
Expand All @@ -339,7 +321,7 @@ if ( window.jQuery ) {
} else {
el.closest('td').addClass('qm-toggled-on');
el.text(el.attr('data-off'));
toggle.slideToggle(150);
toggle.slideToggle(200);
}
e.preventDefault();
});
Expand Down
11 changes: 3 additions & 8 deletions query-monitor/classes/Activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ public function activate( $sitewide = false ) {
$db = WP_CONTENT_DIR . '/db.php';
$create_symlink = defined( 'QM_DB_SYMLINK' ) ? QM_DB_SYMLINK : true;

if ( $create_symlink && defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS ) {
$create_symlink = false;
}

if ( $create_symlink && ! file_exists( $db ) && function_exists( 'symlink' ) ) {
@symlink( $this->plugin_path( 'wp-content/db.php' ), $db ); // phpcs:ignore
}
Expand All @@ -49,19 +45,18 @@ public function activate( $sitewide = false ) {
}

/**
* @param bool $network_wide
* @return void
*/
public function deactivate( $network_wide = false ) {
public function deactivate() {
$admins = QM_Util::get_admins();

// Remove legacy capability handling:
if ( $admins ) {
$admins->remove_cap( 'view_query_monitor' );
}

# Only delete db.php if a single site and db.php belongs to Query Monitor
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && class_exists( 'QM_DB', false ) && ( $network_wide || ! is_multisite() ) ) {
# Only delete db.php if it belongs to Query Monitor
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && class_exists( 'QM_DB', false ) ) {
unlink( WP_CONTENT_DIR . '/db.php' ); // phpcs:ignore
}

Expand Down
40 changes: 16 additions & 24 deletions query-monitor/classes/Backtrace.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ class QM_Backtrace {
'Altis\Cloud\DB' => true,
'Yoast\WP\Lib\ORM' => true,
'Perflab_SQLite_DB' => true,
'WP_SQLite_DB' => true,
);

/**
* @var array<string, array<string, bool>>
* @var array<string, bool>
*/
protected static $ignore_method = array();

Expand All @@ -47,12 +46,9 @@ class QM_Backtrace {
'trigger_error' => true,
'_doing_it_wrong' => true,
'_deprecated_argument' => true,
'_deprecated_constructor' => true,
'_deprecated_file' => true,
'_deprecated_function' => true,
'_deprecated_hook' => true,
'dbDelta' => true,
'maybe_create_table' => true,
);

/**
Expand Down Expand Up @@ -100,9 +96,9 @@ class QM_Backtrace {
protected $args = array();

/**
* @var mixed[]
* @var mixed[]|null
*/
protected $trace;
protected $trace = null;

/**
* @var mixed[]|null
Expand Down Expand Up @@ -225,10 +221,7 @@ public function get_component() {
}
}

$file_dirs = QM_Util::get_file_dirs();
$file_dirs['dropin'] = WP_CONTENT_DIR;

foreach ( $file_dirs as $type => $dir ) {
foreach ( QM_Util::get_file_dirs() as $type => $dir ) {
if ( isset( $components[ $type ] ) ) {
$this->component = $components[ $type ];
return $this->component;
Expand Down Expand Up @@ -411,8 +404,8 @@ public function filter_trace( array $frame ) {
*
* @since 2.7.0
*
* @param array<string, bool> $ignore_class Array of class names to ignore. The array keys are class names to ignore,
* the array values are whether to ignore the class (usually true).
* @param bool[] $ignore_class Array of class names to ignore. The array keys are class names to ignore,
* the array values are whether to ignore the class or not (usually true).
*/
self::$ignore_class = apply_filters( 'qm/trace/ignore_class', self::$ignore_class );

Expand All @@ -421,9 +414,8 @@ public function filter_trace( array $frame ) {
*
* @since 2.7.0
*
* @param array<string, array<string, bool>> $ignore_method Array of method names to ignore. The top level array keys are
* class names, the second level array keys are method names, and
* the array values are whether to ignore the method (usually true).
* @param bool[] $ignore_method Array of method names to ignore. The array keys are method names to ignore,
* the array values are whether to ignore the method or not (usually true).
*/
self::$ignore_method = apply_filters( 'qm/trace/ignore_method', self::$ignore_method );

Expand All @@ -432,18 +424,18 @@ public function filter_trace( array $frame ) {
*
* @since 2.7.0
*
* @param array<string, bool> $ignore_func Array of function names to ignore. The array keys are function names to ignore,
* the array values are whether to ignore the function (usually true).
* @param bool[] $ignore_func Array of function names to ignore. The array keys are function names to ignore,
* the array values are whether to ignore the function or not (usually true).
*/
self::$ignore_func = apply_filters( 'qm/trace/ignore_func', self::$ignore_func );

/**
* Filters which action and filter names to ignore when constructing user-facing call stacks.
*
* @since 3.8.0
* @since x.x.x
*
* @param array<string, bool> $ignore_hook Array of hook names to ignore. The array keys are hook names to ignore,
* the array values are whether to ignore the hook (usually true).
* @param bool[] $ignore_hook Array of hook names to ignore. The array keys are hook names to ignore,
* the array values are whether to ignore the hook or not (usually true).
*/
self::$ignore_hook = apply_filters( 'qm/trace/ignore_hook', self::$ignore_hook );

Expand All @@ -453,9 +445,9 @@ public function filter_trace( array $frame ) {
*
* @since 2.7.0
*
* @param array<string,int|string> $show_args The number of argument values to show for the given function name. The
* array keys are function names, the array values are either integers or
* "dir" to specifically treat the function argument as a directory path.
* @param (int|string)[] $show_args The number of argument values to show for the given function name. The
* array keys are function names, the array values are either integers or
* "dir" to specifically treat the function argument as a directory path.
*/
self::$show_args = apply_filters( 'qm/trace/show_args', self::$show_args );

Expand Down
16 changes: 7 additions & 9 deletions query-monitor/classes/Collector.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ public static function format_bool_constant( $constant ) {
if ( ! defined( $constant ) ) {
/* translators: Undefined PHP constant */
return __( 'undefined', 'query-monitor' );
} elseif ( constant( $constant ) === '' ) {
return __( 'empty string', 'query-monitor' );
} elseif ( is_string( constant( $constant ) ) && ! is_numeric( constant( $constant ) ) ) {
return constant( $constant );
} elseif ( ! constant( $constant ) ) {
Expand Down Expand Up @@ -175,7 +173,7 @@ final public function process_concerns() {
*
* @since 3.3.0
*
* @param array<int, string> $actions Array of action names that this panel concerns itself with.
* @param string[] $actions Array of action names that this panel concerns itself with.
*/
$concerned_actions = apply_filters( "qm/collect/concerned_actions/{$id}", $this->get_concerned_actions() );

Expand All @@ -187,7 +185,7 @@ final public function process_concerns() {
*
* @since 3.3.0
*
* @param array<int, string> $filters Array of filter names that this panel concerns itself with.
* @param string[] $filters Array of filter names that this panel concerns itself with.
*/
$concerned_filters = apply_filters( "qm/collect/concerned_filters/{$id}", $this->get_concerned_filters() );

Expand All @@ -199,7 +197,7 @@ final public function process_concerns() {
*
* @since 3.3.0
*
* @param array<int, string> $options Array of option names that this panel concerns itself with.
* @param string[] $options Array of option names that this panel concerns itself with.
*/
$concerned_options = apply_filters( "qm/collect/concerned_options/{$id}", $this->get_concerned_options() );

Expand All @@ -211,20 +209,20 @@ final public function process_concerns() {
*
* @since 3.3.0
*
* @param array<int, string> $constants Array of constant names that this panel concerns itself with.
* @param string[] $constants Array of constant names that this panel concerns itself with.
*/
$concerned_constants = apply_filters( "qm/collect/concerned_constants/{$id}", $this->get_concerned_constants() );

foreach ( $concerned_actions as $action ) {
if ( has_action( $action ) ) {
$this->concerned_actions[ $action ] = QM_Hook::process( $action, 'action', $wp_filter, true, false );
$this->concerned_actions[ $action ] = QM_Hook::process( $action, $wp_filter, true, false );
}
$tracked[] = $action;
}

foreach ( $concerned_filters as $filter ) {
if ( has_filter( $filter ) ) {
$this->concerned_filters[ $filter ] = QM_Hook::process( $filter, 'filter', $wp_filter, true, false );
$this->concerned_filters[ $filter ] = QM_Hook::process( $filter, $wp_filter, true, false );
}
$tracked[] = $filter;
}
Expand All @@ -246,7 +244,7 @@ final public function process_concerns() {
$option
);
if ( has_filter( $filter ) ) {
$this->concerned_filters[ $filter ] = QM_Hook::process( $filter, 'filter', $wp_filter, true, false );
$this->concerned_filters[ $filter ] = QM_Hook::process( $filter, $wp_filter, true, false );
}
$tracked[] = $filter;
}
Expand Down
2 changes: 1 addition & 1 deletion query-monitor/classes/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function cease() {
* Processes and fetches the outputters for this dispatcher.
*
* @param string $outputter_id The outputter ID.
* @return array<string, QM_Output> Array of outputters.
* @return QM_Output[] Array of outputters.
*/
public function get_outputters( $outputter_id ) {
$collectors = QM_Collectors::init();
Expand Down
Loading

0 comments on commit 9bb1580

Please sign in to comment.