log_query_custom_data filter-hookWP 5.3.0

Filters the custom data to log alongside a query.

Caution should be used when modifying any of this data, it is recommended that any additional information you need to store about a query be added as a new associative array element.

Usage

add_filter( 'log_query_custom_data', 'wp_kama_log_query_custom_data_filter', 10, 5 );

/**
 * Function for `log_query_custom_data` filter-hook.
 * 
 * @param array  $query_data      Custom query data.
 * @param string $query           The query's SQL.
 * @param float  $query_time      Total time spent on the query, in seconds.
 * @param string $query_callstack Comma-separated list of the calling functions.
 * @param float  $query_start     Unix timestamp of the time at the start of the query.
 *
 * @return array
 */
function wp_kama_log_query_custom_data_filter( $query_data, $query, $query_time, $query_callstack, $query_start ){

	// filter...
	return $query_data;
}
$query_data(array)
Custom query data.
$query(string)
The query's SQL.
$query_time(float)
Total time spent on the query, in seconds.
$query_callstack(string)
Comma-separated list of the calling functions.
$query_start(float)
Unix timestamp of the time at the start of the query.

Changelog

Since 5.3.0 Introduced.

Where the hook is called

wpdb::log_query()
log_query_custom_data
wp-includes/class-wpdb.php 2230
$query_data = apply_filters( 'log_query_custom_data', $query_data, $query, $query_time, $query_callstack, $query_start );

Where the hook is used in WordPress

Usage not found.