Headers have already been sent after upgrade to Drupal 9.2 (can't login)

Created on 20 May 2021, over 3 years ago
Updated 2 November 2023, 11 months ago

Problem/Motivation

Since Drupal 9.2, this module does not work correctly anymore. The troublesome change seems to be https://www.drupal.org/node/3006306

Proposed resolution

There are currently two active avenues:

  • Patch #25; introduce a middleware
  • Patch #107; introduce a destination parameter in the current request

#25

This introduces a middleware to implement the module's functionality. There were some doubts about whether this would not be too heavy, and whether it would not make more sense to only trigger on submission of the login form, which larowlan had this to say about over in #45 🐛 Headers have already been sent after upgrade to Drupal 9.2 (can't login) Fixed :

Please see comment #37, this module supports more than form-based login at present.

Is that an acceptable compromise?

It would be nice to find some alternative strategy, maybe event-based.

The only suitable event would be the ResponseEvent from the Kernel, and that also runs on every request, so its a comparable amount either way.

Regardless, all we're adding is one __construct call, one extra function call (to call the inner kernel) and a ternary.

#107

This simply adds a destination parameter to the current request.

Remaining tasks

  • Decide which approach to take.
  • Apply patch/merge
  • Make a release that is actually compatible with the currently supported versions of Drupal 9 (Drupal 10 is a separate matter)

User interface changes

None.

API changes

None.

Data model changes

None.

Original report by Cangurin limpiezas

Hi, i have problems to login when i update from drupal 9.18 to drupal-9.2.0-alpha1
after upgrade i continue in login, all ok
but when i logout and try login again ,
in apache log i get the next error

[Wed May 19 21:49:41.463707 2021] [php7:notice] [pid 45161] [client 127.0.0.1:50796] RuntimeException: Failed to start the session because headers have already been sent by "/var/www/html/c19052021/vendor/symfony/http-foundation/Response.php" at line 1224. in /var/www/html/c19052021/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php on line 152 #0 /var/www/html/c19052021/core/lib/Drupal/Core/Session/SessionManager.php(162): Symfony\\Component\\HttpFoundation\\Session\\Storage\\NativeSessionStorage->start()\n#1 /var/www/html/c19052021/core/lib/Drupal/Core/Session/SessionManager.php(193): Drupal\\Core\\Session\\SessionManager->startNow()\n#2 /var/www/html/c19052021/vendor/symfony/http-foundation/Session/Session.php(189): Drupal\\Core\\Session\\SessionManager->save()\n#3 /var/www/html/c19052021/core/lib/Drupal/Core/StackMiddleware/Session.php(60): Symfony\\Component\\HttpFoundation\\Session\\Session->save()\n#4 /var/www/html/c19052021/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\\Core\\StackMiddleware\\Session->handle()\n#5 /var/www/html/c19052021/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\\Core\\StackMiddleware\\KernelPreHandle->handle()\n#6 /var/www/html/c19052021/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\\page_cache\\StackMiddleware\\PageCache->pass()\n#7 /var/www/html/c19052021/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\\page_cache\\StackMiddleware\\PageCache->handle()\n#8 /var/www/html/c19052021/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\\Core\\StackMiddleware\\ReverseProxyMiddleware->handle()\n#9 /var/www/html/c19052021/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\\Core\\StackMiddleware\\NegotiationMiddleware->handle()\n#10 /var/www/html/c19052021/core/lib/Drupal/Core/DrupalKernel.php(716): Stack\\StackedHttpKernel->handle()\n#11 /var/www/html/c19052021/index.php(19): Drupal\\Core\\DrupalKernel->handle()\n#12 {main}, referer: http://www.localhost/c19052021/user/login

if i delete the module with
drush pm-uninstall redirect_after_login

i can enter to my account without problems,
any help?
Thanks.

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇪🇸Spain Cangurin limpiezas Zaragoza

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

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.

Production build 0.71.5 2024