Skip to content

Commit

Permalink
fixed backtrace in search_api_solr_log
Browse files Browse the repository at this point in the history
  • Loading branch information
mkalkbrenner committed Jan 27, 2025
1 parent c682e44 commit 4306e7f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/search_api_solr_log/src/Logger/SolrLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function log($level, string|\Stringable $message, array $context = []): v
}
// Remove backtrace and exception since they may contain
// an unserializable variable.
unset($context['exception']);
unset($context['backtrace'], $context['exception']);
try {
$connector = self::getConnector();
} catch (SearchApiException $e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,18 @@ public function render(ResultRow $values): string {
$variables_json = $values->{'solr_document/zs_variables'}[0] ?? '{}';
$variables = json_decode($variables_json, TRUE);

if ($variables === NULL) {
return Xss::filterAdmin($value);
}

// Ensure backtrace strings are properly formatted.
if (isset($variables['@backtrace_string'])) {
$variables['@backtrace_string'] = new FormattableMarkup(
'<pre class="backtrace">@backtrace_string</pre>', $variables
);
if (!str_contains($value, '@backtrace_string')) {
$value .= ' @backtrace_string';
}
}

return $this->t(Xss::filterAdmin($value), (array) $variables)->render();
Expand Down

0 comments on commit 4306e7f

Please sign in to comment.