Skip to content

Commit e40d2c4

Browse files
committed
Align the details of the benchmark’s stacktrace with the exceptions
This is now in line with the exceptions and makes it clear where a call happens. This was previously quite confusing because the line is where the call in the file (!) took place that invoked said method. The line refers to the callee and not to a line within the class being listed.
1 parent 06ce93d commit e40d2c4

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

com.woltlab.wcf/templates/shared_benchmark.tpl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,17 @@
2424
<ol class="nativeList" start="0">
2525
{foreach from=$item.trace item=traceItem}
2626
<li>
27-
{if !$traceItem.class|empty}{$traceItem.class}{$traceItem.type}{else}{if !$traceItem.file|empty}{$traceItem.file}: {/if}{/if}{$traceItem.function}() {if !$traceItem.line|empty}(line {#$traceItem.line}){/if}
27+
{if !$traceItem.class|empty}{*
28+
*}{$traceItem.class}{$traceItem.type}{*
29+
*}{elseif !$traceItem.file|empty}{*
30+
*}{$traceItem.file}: {*
31+
*}{/if}{*
32+
*}{$traceItem.function}()
33+
<span class="benchmark__stacktrace__context">
34+
{$traceItem[file]}{if !$traceItem.line|empty}{*
35+
*}:{#$traceItem.line}{*
36+
*}{/if}
37+
</span>
2838
</li>
2939
{/foreach}
3040
</ol>

wcfsetup/install/files/lib/system/benchmark/Benchmark.class.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,17 @@ static function ($index) use ($startOfMiddleware, $endOfMiddleware) {
115115
);
116116
}
117117

118+
foreach ($backtrace as &$segment) {
119+
if (!isset($segment['file'])) {
120+
continue;
121+
}
122+
123+
if (preg_match('~^(' . preg_quote($_SERVER['DOCUMENT_ROOT'], '~') . '|' . preg_quote(WCF_DIR, '~') . ')~', $segment['file'])) {
124+
$segment['file'] = '*/' . FileUtil::removeTrailingSlash(FileUtil::getRelativePath(WCF_DIR, $segment['file']));
125+
}
126+
}
127+
unset($segment);
128+
118129
$this->items[$newIndex]['trace'] = $backtrace;
119130

120131
return $newIndex;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
.benchmarkDetails .hot {
22
color: var(--wcfStatusErrorText);
33
}
4+
5+
.benchmark__stacktrace__context {
6+
color: var(--wcfContentDimmedText);
7+
display: block;
8+
9+
@include wcfFontSmall;
10+
}

0 commit comments

Comments
 (0)