Fix potentially erroneous response size in debug output #2546

This commit is contained in:
Kijin 2025-04-28 21:46:45 +09:00
parent 24e90e43fa
commit cac3ec1165

View file

@ -9,7 +9,6 @@ class DisplayHandler extends Handler
{ {
public static $response_size = 0; public static $response_size = 0;
public static $debug_printed = 0; public static $debug_printed = 0;
public $content_size = 0;
public $handler = NULL; public $handler = NULL;
/** /**
@ -140,12 +139,15 @@ class DisplayHandler extends Handler
$buff = ltrim($buff, "\n\r\t\v\x00\x20\u{FEFF}"); $buff = ltrim($buff, "\n\r\t\v\x00\x20\u{FEFF}");
// call a trigger after display // call a trigger after display
self::$response_size = $this->content_size = strlen($output);
ModuleHandler::triggerCall('display', 'after', $output); ModuleHandler::triggerCall('display', 'after', $output);
// Measure the response size.
self::$response_size = strlen((string)$output);
// Output buffered content only if the current page is HTML. // Output buffered content only if the current page is HTML.
if ($handler instanceof HTMLDisplayHandler) if ($handler instanceof HTMLDisplayHandler)
{ {
self::$response_size += strlen($buff);
echo $buff; echo $buff;
} }