-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Description
Symfony version(s) affected
6.*
Description
PHP version: >=8.1
Symfony version: (probably) any with dependes on PHP>=8.1
Sent HTTP request to my service with no header Content-type
. Testing in dev (or test) mode with debug disabled.
And have error Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /var/www/vendor/symfony/web-profiler-bundle/EventListener/WebDebugToolbarListener.php on line 124
How to reproduce
- Set environments:
APP_ENV=dev
APP_DEBUG=false
WebProfilerBundle
enabled and collects data- Send HTTP request to any endpoint with no
Content-type
header
Possible Solution
Its working for me
--- a/vendor/symfony/web-profiler-bundle/EventListener/WebDebugToolbarListener.php
+++ b/vendor/symfony/web-profiler-bundle/EventListener/WebDebugToolbarListener.php
@@ -121,7 +121,7 @@
if (self::DISABLED === $this->mode
|| !$response->headers->has('X-Debug-Token')
|| $response->isRedirection()
- || ($response->headers->has('Content-Type') && !str_contains($response->headers->get('Content-Type'), 'html'))
+ || ($response->headers->has('Content-Type') && !str_contains($response->headers->get('Content-Type') ?? '', 'html'))
|| 'html' !== $request->getRequestFormat()
|| false !== stripos($response->headers->get('Content-Disposition', ''), 'attachment;')
) {
But unfortunly not working
|| ($response->headers->has('Content-Type') && !str_contains($response->headers->get('Content-Type', ''), 'html'))
Additional Context
No response