Skip to content

Commit

Permalink
Merge pull request #8320 from sbulen/21_err_log_tweak
Browse files Browse the repository at this point in the history
[2.1] Fix blank screens in error log
  • Loading branch information
Sesquipedalian authored Feb 4, 2025
2 parents b1a8718 + 9e1f256 commit d5b91f9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Sources/Subs.php
Original file line number Diff line number Diff line change
Expand Up @@ -3993,7 +3993,7 @@ function highlight_php_code($code)

$oldlevel = error_reporting(0);

$buffer = str_replace(array("\n", "\r"), '', @highlight_string($code, true));
$buffer = str_replace(array("\n", "\r"), array('<br />', ''), @highlight_string($code, true));

error_reporting($oldlevel);

Expand All @@ -4003,6 +4003,10 @@ function highlight_php_code($code)
// PHP 8.3 changed the returned HTML.
$buffer = preg_replace('/^(<pre>)?<code[^>]*>|<\/code>(<\/pre>)?$/', '', $buffer);

// Remove line breaks inserted before & after the actual code in php < 8.3
$buffer = preg_replace('/^(<span\s[^>]*>)<br \/>/', '$1', $buffer);
$buffer = preg_replace('/<br \/>(<\/span[^>]*>)<br \/>$/', '$1', $buffer);

return strtr($buffer, ['\'' => '&#039;']);
}

Expand Down

0 comments on commit d5b91f9

Please sign in to comment.