Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging release v20231121.1 #5039

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions query-monitor/assets/query-monitor.css
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
#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 @@ -175,7 +176,9 @@
#wpadminbar .qm-notice {
background-color: #740;
}
#wpadminbar #wp-admin-bar-query-monitor-stricts a:focus, #wpadminbar #wp-admin-bar-query-monitor-stricts a:hover,
#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-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 @@ -241,6 +244,7 @@ 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 @@ -438,8 +442,8 @@ body.admin-color-light #wp-admin-bar-query-monitor:not(.qm-all-clear):not(:hover
height: 27px;
}
#query-monitor-main.qm-show {
height: 40%;
width: 40%;
height: 60%;
width: 60%;
}
#query-monitor-main:not(.qm-show-right) {
width: 100% !important;
Expand Down Expand Up @@ -602,7 +606,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: 6px 32px 6px 10px !important;
padding: 7px 32px 7px 10px !important;
position: relative !important;
text-decoration: none !important;
width: 100% !important;
Expand Down Expand Up @@ -729,7 +733,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: 5px 5px 4px 5px !important;
padding: 6px 6px 5px 6px !important;
vertical-align: top !important;
}
#query-monitor-main .qm tbody th,
Expand All @@ -742,7 +746,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 !important;
padding: 5px 5px 5px 6px !important;
position: -webkit-sticky !important;
position: sticky !important;
top: 0 !important;
Expand Down Expand Up @@ -785,7 +789,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: 19px !important;
line-height: 20px !important;
}
#query-monitor-main .qm td.qm-row-sql {
min-width: 25em !important;
Expand All @@ -805,7 +809,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: 24px !important;
padding-right: 28px !important;
position: relative !important;
}
#query-monitor-main .qm td.qm-has-toggle:not(.qm-toggled-on) .qm-supplemental {
Expand Down Expand Up @@ -897,6 +901,7 @@ 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 @@ -905,7 +910,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: 19px !important;
line-height: 20px !important;
}
#query-monitor-main .qm pre {
background: transparent !important;
Expand Down Expand Up @@ -1259,7 +1264,8 @@ 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-component,
#query-monitor-main .qm-hide-host {
display: none !important;
}
#query-monitor-main .qm thead th.qm-sortable-column {
Expand Down
26 changes: 22 additions & 4 deletions query-monitor/assets/query-monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,20 +253,38 @@ 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 = matches.length + ' / ' + tr.length;
var count = filtered_count + ' / ' + total_count;
} else {
var count = matches.length;
var count = filtered_count;
}

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

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

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

# Only delete db.php if it belongs to Query Monitor
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && class_exists( 'QM_DB', false ) ) {
# 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() ) ) {
unlink( WP_CONTENT_DIR . '/db.php' ); // phpcs:ignore
}

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

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

Expand All @@ -46,9 +47,12 @@ 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 @@ -96,9 +100,9 @@ class QM_Backtrace {
protected $args = array();

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

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

foreach ( QM_Util::get_file_dirs() as $type => $dir ) {
$file_dirs = QM_Util::get_file_dirs();
$file_dirs['dropin'] = WP_CONTENT_DIR;

foreach ( $file_dirs as $type => $dir ) {
if ( isset( $components[ $type ] ) ) {
$this->component = $components[ $type ];
return $this->component;
Expand Down Expand Up @@ -404,8 +411,8 @@ public function filter_trace( array $frame ) {
*
* @since 2.7.0
*
* @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).
* @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).
*/
self::$ignore_class = apply_filters( 'qm/trace/ignore_class', self::$ignore_class );

Expand All @@ -414,8 +421,9 @@ public function filter_trace( array $frame ) {
*
* @since 2.7.0
*
* @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).
* @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).
*/
self::$ignore_method = apply_filters( 'qm/trace/ignore_method', self::$ignore_method );

Expand All @@ -424,18 +432,18 @@ public function filter_trace( array $frame ) {
*
* @since 2.7.0
*
* @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).
* @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).
*/
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 x.x.x
* @since 3.8.0
*
* @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).
* @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).
*/
self::$ignore_hook = apply_filters( 'qm/trace/ignore_hook', self::$ignore_hook );

Expand All @@ -445,9 +453,9 @@ public function filter_trace( array $frame ) {
*
* @since 2.7.0
*
* @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.
* @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.
*/
self::$show_args = apply_filters( 'qm/trace/show_args', self::$show_args );

Expand Down
16 changes: 9 additions & 7 deletions query-monitor/classes/Collector.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ 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 @@ -173,7 +175,7 @@ final public function process_concerns() {
*
* @since 3.3.0
*
* @param string[] $actions Array of action names that this panel concerns itself with.
* @param array<int, 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 @@ -185,7 +187,7 @@ final public function process_concerns() {
*
* @since 3.3.0
*
* @param string[] $filters Array of filter names that this panel concerns itself with.
* @param array<int, 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 @@ -197,7 +199,7 @@ final public function process_concerns() {
*
* @since 3.3.0
*
* @param string[] $options Array of option names that this panel concerns itself with.
* @param array<int, 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 @@ -209,20 +211,20 @@ final public function process_concerns() {
*
* @since 3.3.0
*
* @param string[] $constants Array of constant names that this panel concerns itself with.
* @param array<int, 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, $wp_filter, true, false );
$this->concerned_actions[ $action ] = QM_Hook::process( $action, 'action', $wp_filter, true, false );
}
$tracked[] = $action;
}

foreach ( $concerned_filters as $filter ) {
if ( has_filter( $filter ) ) {
$this->concerned_filters[ $filter ] = QM_Hook::process( $filter, $wp_filter, true, false );
$this->concerned_filters[ $filter ] = QM_Hook::process( $filter, 'filter', $wp_filter, true, false );
}
$tracked[] = $filter;
}
Expand All @@ -244,7 +246,7 @@ final public function process_concerns() {
$option
);
if ( has_filter( $filter ) ) {
$this->concerned_filters[ $filter ] = QM_Hook::process( $filter, $wp_filter, true, false );
$this->concerned_filters[ $filter ] = QM_Hook::process( $filter, 'filter', $wp_filter, true, false );
}
$tracked[] = $filter;
}
Expand Down
Loading
Loading