From f796aeb660a8f2c67b646b521f05d1823c360447 Mon Sep 17 00:00:00 2001 From: Yoann MOROCUTTI Date: Wed, 8 Oct 2025 14:22:04 +0200 Subject: [PATCH] fix: Fix an issue where profiler is calling a unknown Twig filter named json_decode. Create a filter named simple_json_decode and use it instead [twig-filter] --- Resources/views/Collector/partials/auth.html.twig | 8 ++++---- Twig/Extension.php | 12 ++---------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/Resources/views/Collector/partials/auth.html.twig b/Resources/views/Collector/partials/auth.html.twig index 1d92ab3..a34a128 100644 --- a/Resources/views/Collector/partials/auth.html.twig +++ b/Resources/views/Collector/partials/auth.html.twig @@ -10,8 +10,8 @@ Request {% if call.request and call.request.jwt|default(false) %} - {{ dump(call.request.jwt.decoded.header|json_decode) }} - {{ dump(call.request.jwt.decoded.payload|json_decode) }} + {{ dump(call.request.jwt.decoded.header|simple_json_decode) }} + {{ dump(call.request.jwt.decoded.payload|simple_json_decode) }} {% endif %} @@ -19,8 +19,8 @@ Response {% if call.response and call.response.jwt|default(false) %} - {{ dump(call.response.jwt.decoded.header|json_decode) }} - {{ dump(call.response.jwt.decoded.payload|json_decode) }} + {{ dump(call.response.jwt.decoded.header|simple_json_decode) }} + {{ dump(call.response.jwt.decoded.payload|simple_json_decode) }} {% endif %} diff --git a/Twig/Extension.php b/Twig/Extension.php index 8fea4ec..ffe795a 100644 --- a/Twig/Extension.php +++ b/Twig/Extension.php @@ -33,10 +33,11 @@ public function getFilters(): array new TwigFilter('simple_http_beautify', array($this, 'format'), $safe), new TwigFilter('simple_http_format_http_code', array($this, 'formatHttpCode'), $safe), new TwigFilter('simple_http_format_http_code_as_badge', array($this, 'formatHttpCodeAsSfBadge'), $safe), - new TwigFilter('simple_http_md5', array($this, 'md5')), + new TwigFilter('simple_http_md5', 'md5'), new TwigFilter('simple_http_include_asset', array($this, 'assetInclude'), $safe), new TwigFilter('simple_http_format_ms', array($this, 'formatMilliseconds')), new TwigFilter('simple_http_format_num', array($this, 'numberFormat')), + new TwigFilter('simple_json_decode', 'json_decode'), ]; } @@ -72,15 +73,6 @@ public function formatMilliseconds($ms): string return $this->numberFormat($ms * 1000) . " ms"; } - /** - * @param $str - * @return string - */ - public function md5($str): string - { - return md5($str); - } - public function assetInclude(string $file): string { try {