Argument #2 ($status) must be of type int, null given, called

Created on 28 February 2021, over 3 years ago
Updated 2 April 2024, 8 months ago

Hi!

On a fresh Drupal 9 migrated from a Drupal 7, I have this error:

TypeError : Symfony\Component\HttpFoundation\RedirectResponse::__construct(): Argument #2 ($status) must be of type int, null given, called in /home/mywebuser/mydomain.com/public_html/web/core/lib/Drupal/Core/Routing/TrustedRedirectResponse.php on line 26 dans Symfony\Component\HttpFoundation\RedirectResponse->__construct() (/home/mywebuser/mydomain.com/public_html/vendor/symfony/http-foundation/RedirectResponse.php ligne 35)

#0 /home/mywebuser/mydomain.com/public_html/web/core/lib/Drupal/Core/Routing/TrustedRedirectResponse.php(26): Symfony\Component\HttpFoundation\RedirectResponse->__construct()
#1 /home/mywebuser/mydomain.com/public_html/web/modules/contrib/redirect/src/EventSubscriber/RedirectRequestSubscriber.php(166): Drupal\Core\Routing\TrustedRedirectResponse->__construct()
#2 [internal function]: Drupal\redirect\EventSubscriber\RedirectRequestSubscriber->onKernelRequestCheckRedirect()
#3 /home/mywebuser/mydomain.com/public_html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func()
#4 /home/mywebuser/mydomain.com/public_html/vendor/symfony/http-kernel/HttpKernel.php(134): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()
#5 /home/mywebuser/mydomain.com/public_html/vendor/symfony/http-kernel/HttpKernel.php(80): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#6 /home/mywebuser/mydomain.com/public_html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle()
#7 /home/mywebuser/mydomain.com/public_html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle()
#8 /home/mywebuser/mydomain.com/public_html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#9 /home/mywebuser/mydomain.com/public_html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#10 /home/mywebuser/mydomain.com/public_html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle()
#11 /home/mywebuser/mydomain.com/public_html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#12 /home/mywebuser/mydomain.com/public_html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#13 /home/mywebuser/mydomain.com/public_html/web/core/lib/Drupal/Core/DrupalKernel.php(706): Stack\StackedHttpKernel->handle()
#14 /home/mywebuser/mydomain.com/public_html/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#15 {main}

I can not help better… sorry

Regards

πŸ› Bug report
Status

Postponed: needs info

Version

1.8

Component

Code

Created by

πŸ‡«πŸ‡·France floown

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡«πŸ‡·France floown

    Hello,

    Since I have made my site in production, I have seen a lot the error500 appear in Seolyzer and Google Search Console.

    Here is my Drupal logs:

    TypeError : Symfony\Component\HttpFoundation\RedirectResponse::__construct(): Argument #2 ($status) must be of type int, null given, called in /home/myuser/web/mysite/public_html/web/core/lib/Drupal/Core/Routing/TrustedRedirectResponse.php on line 26 dans Symfony\Component\HttpFoundation\RedirectResponse->__construct() (/home/myuser/web/mysite/public_html/vendor/symfony/http-foundation/RedirectResponse.php ligne 35)
    
    #0 /home/myuser/web/mysite/public_html/web/core/lib/Drupal/Core/Routing/TrustedRedirectResponse.php(26): Symfony\Component\HttpFoundation\RedirectResponse->__construct()
    #1 /home/myuser/web/mysite/public_html/web/modules/contrib/redirect/src/EventSubscriber/RedirectRequestSubscriber.php(166): Drupal\Core\Routing\TrustedRedirectResponse->__construct()
    #2 [internal function]: Drupal\redirect\EventSubscriber\RedirectRequestSubscriber->onKernelRequestCheckRedirect()
    #3 /home/myuser/web/mysite/public_html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func()
    #4 /home/myuser/web/mysite/public_html/vendor/symfony/http-kernel/HttpKernel.php(145): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()
    #5 /home/myuser/web/mysite/public_html/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
    #6 /home/myuser/web/mysite/public_html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
    #7 /home/myuser/web/mysite/public_html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
    #8 /home/myuser/web/mysite/public_html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(191): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
    #9 /home/myuser/web/mysite/public_html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(128): Drupal\page_cache\StackMiddleware\PageCache->fetch()
    #10 /home/myuser/web/mysite/public_html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(82): Drupal\page_cache\StackMiddleware\PageCache->lookup()
    #11 /home/myuser/web/mysite/public_html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
    #12 /home/myuser/web/mysite/public_html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
    #13 /home/myuser/web/mysite/public_html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
    #14 /home/myuser/web/mysite/public_html/web/core/lib/Drupal/Core/DrupalKernel.php(713): Stack\StackedHttpKernel->handle()
    #15 /home/myuser/web/mysite/public_html/web/index.php(19): Drupal\Core\DrupalKernel->handle()
    #16 {main}

    So the patch integrated in the other issue pointed by #7 is not good for my problem.

    I’m not a developer, just a user. So I can't help more.

  • Status changed to Active almost 2 years ago
  • Status changed to Fixed over 1 year ago
  • Status changed to Postponed: needs info over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States Kristen Pol Santa Cruz, CA, USA

    @floown I'm not sure why you have marked this fixed. Several people have had the same issue. Did you find something that fixed this issue for you?

  • πŸ‡«πŸ‡·France floown

    Hi Kristen,

    In fact, I have edit manually all the redirection that haven't switched to 301 code by default.

    I have report to the 301 I had manually add in my .htaccess for respons quickly to error 500 I had.

    My problem seems to be solved.

  • πŸ‡ΊπŸ‡ΈUnited States Rick Hood

    I have this issue, also from long ago Drupal 7 to 8 migration. Nobody ever reported any kind of issue, but I can see lots of errors in the logs.
    Running this on my local database, then clearing cache seems to fix it:

    UPDATE redirect
    SET status_code = 301
    WHERE status_code IS NULL;

    There are 3024 NULL status codes that the above changes to 301.
    My question: is this safe? I virtually never run commands in the database so it scares me a bit.
    ;-)
    Thanks,
    Rick

Production build 0.71.5 2024