| Server IP : 145.239.37.162 / Your IP : 216.73.216.77 Web Server : Apache System : Linux webm003.cluster130.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64 User : verseaa ( 38250) PHP Version : 7.4.33 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/verseaa/www/wp-content/plugins/query-monitor/output/headers/ |
Upload File : |
<?php declare(strict_types = 1);
/**
* PHP error output for HTTP headers.
*
* @package query-monitor
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class QM_Output_Headers_PHP_Errors extends QM_Output_Headers {
/**
* Collector instance.
*
* @var QM_Collector_PHP_Errors Collector.
*/
protected $collector;
/**
* @return array<string, mixed>
*/
public function get_output() {
/** @var QM_Data_PHP_Errors $data */
$data = $this->collector->get_data();
$headers = array();
if ( empty( $data->errors ) ) {
return array();
}
$count = 0;
foreach ( $data->errors as $error ) {
$count++;
$stack = isset( $error->trace ) ? $error->trace->get_stack() : array();
$component = isset( $error->trace ) ? $error->trace->get_component()->name : '';
$callsite = isset( $error->trace ) ? $error->trace->get_callsite() : null;
$output_error = array(
'level' => $error->level,
'message' => $error->message,
'file' => $callsite ? QM_Util::standard_dir( $callsite->file, '' ) : '',
'line' => $callsite->line ?? null,
'stack' => $stack,
'component' => $component,
);
$key = sprintf( 'error-%d', $count );
$headers[ $key ] = wp_json_encode( $output_error );
}
return array_merge(
array(
'count' => $count,
),
$headers
);
}
}
/**
* @param array<string, QM_Output> $output
* @param QM_Collectors $collectors
* @return array<string, QM_Output>
*/
function register_qm_output_headers_php_errors( array $output, QM_Collectors $collectors ) {
$collector = QM_Collectors::get( 'php_errors' );
if ( $collector ) {
$output['php_errors'] = new QM_Output_Headers_PHP_Errors( $collector );
}
return $output;
}
add_filter( 'qm/outputter/headers', 'register_qm_output_headers_php_errors', 110, 2 );