Short query source files (#1505)

This commit is contained in:
Barry vd. Heuvel 2024-02-10 11:47:47 +01:00 committed by GitHub
parent 4ea517bb2c
commit 3b7c3a53d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 8 deletions

View File

@ -504,7 +504,8 @@ class QueryCollector extends PDOCollector
'duration_str' => ($query['type'] == 'transaction') ? '' : $this->formatDuration($query['time']),
'memory' => $query['memory'],
'memory_str' => $query['memory'] ? $this->getDataFormatter()->formatBytes($query['memory']) : null,
'stmt_id' => $this->getDataFormatter()->formatSource($source),
'filename' => $this->getDataFormatter()->formatSource($source, true),
'source' => $this->getDataFormatter()->formatSource($source),
'xdebug_link' => is_object($source) ? $this->getXdebugLink($source->file ?: '', $source->line) : null,
'connection' => $query['connection'],
];

View File

@ -68,7 +68,7 @@ class QueryFormatter extends DataFormatter
* @param object|null $source If the backtrace is disabled, the $source will be null.
* @return string
*/
public function formatSource($source)
public function formatSource($source, $short = false)
{
if (! is_object($source)) {
return '';
@ -76,11 +76,11 @@ class QueryFormatter extends DataFormatter
$parts = [];
if ($source->namespace) {
if (!$short && $source->namespace) {
$parts['namespace'] = $source->namespace . '::';
}
$parts['name'] = $source->name;
$parts['name'] = $short ? basename($source->name) : $source->name;
$parts['line'] = ':' . $source->line;
return implode($parts);

View File

@ -82,10 +82,11 @@
if (typeof(stmt.row_count) != 'undefined') {
$('<span title="Row count" />').addClass(csscls('row-count')).text(stmt.row_count).appendTo(li);
}
if (typeof(stmt.stmt_id) != 'undefined' && stmt.stmt_id) {
$('<span title="Prepared statement ID" />').addClass(csscls('stmt-id'))
.append(! stmt.xdebug_link ? $('<i/>').text(stmt.stmt_id).html() : $('<a />')
.attr('href', stmt.xdebug_link.url).text(stmt.stmt_id)
if (typeof(stmt.filename) != 'undefined' && stmt.filename) {
$('<span title="Source file" />').addClass(csscls('source-file'))
.append(! stmt.xdebug_link ? $('<i/>').text(stmt.filename).html() : $('<a />')
.attr('href', stmt.xdebug_link.url).text(stmt.filename)
.attr('title', stmt.source)
.on('click', function (event) {
event.stopPropagation();
if (stmt.xdebug_link.ajax) {