| Server IP : 145.239.37.162 / Your IP : 216.73.217.74 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/v/e/r/verseaa/www/wp-content/plugins/query-monitor/classes/ |
Upload File : |
<?php declare(strict_types = 1);
/**
* Frame registry for deduplicating stack trace frames in JSON output.
*
* Frames are keyed by their ID but its numeric index is also stored for memory-efficient JSON output.
*
* @package query-monitor
*/
class QM_Frame_Registry {
/**
* Unique frames keyed by "id\0args\0file".
*
* @var array<string, int>
*/
private static $index = array();
/**
* Ordered list of unique frames.
*
* @var list<QM_Data_Stack_Frame>
*/
private static $frames = array();
/**
* Register a frame (without line number) and return its index.
*/
public static function register( QM_Data_Stack_Frame $frame ): int {
$key = $frame->id . "\0" . ( $frame->args ?? '' ) . "\0" . ( $frame->file ?? '' );
if ( isset( self::$index[ $key ] ) ) {
return self::$index[ $key ];
}
$count = count( self::$frames );
$lookup_frame = new QM_Data_Stack_Frame();
$lookup_frame->id = $frame->id;
$lookup_frame->file = $frame->file;
if ( $frame->args !== null ) {
$lookup_frame->args = $frame->args;
} else {
unset( $lookup_frame->args );
}
unset( $lookup_frame->line );
self::$frames[] = $lookup_frame;
self::$index[ $key ] = $count;
return $count;
}
public static function get_frame( int $index ): QM_Data_Stack_Frame {
return self::$frames[ $index ];
}
/**
* @return list<QM_Data_Stack_Frame>
*/
public static function get_frames(): array {
return self::$frames;
}
}