[VarDumper] Backport handler lock when using VAR_DUMPER_FORMAT

This commit is contained in:
Maxime Steinhausser 2020-08-14 16:49:01 +02:00
parent 0bb2a1a918
commit 19b341e2b2
2 changed files with 7 additions and 7 deletions

View File

@ -235,13 +235,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
--$i;
}
if (isset($_SERVER['VAR_DUMPER_FORMAT'])) {
$html = 'html' === $_SERVER['VAR_DUMPER_FORMAT'];
} else {
$html = !\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && stripos($h[$i], 'html');
}
if ($html) {
if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && stripos($h[$i], 'html')) {
$dumper = new HtmlDumper('php://output', $this->charset);
$dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]);
} else {

View File

@ -53,6 +53,12 @@ class VarDumper
public static function setHandler(callable $callable = null)
{
$prevHandler = self::$handler;
// Prevent replacing the handler with expected format as soon as the env var was set:
if (isset($_SERVER['VAR_DUMPER_FORMAT'])) {
return $prevHandler;
}
self::$handler = $callable;
return $prevHandler;