Whilst registering or logging in through Twitter the following 2 Exceptions are thrown and show up in the Watchdog log.

The registration/logging in still works as expected.

LogicException: The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early. Returned object class: Drupal\Core\Routing\TrustedRedirectResponse. in Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (line 154 of /.../docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php).
RuntimeException: Failed to start the session because headers have already been sent by "/.../vendor/symfony/http-foundation/Response.php" at line 1286. in Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start() (line 141 of /.../vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php) #0 /.../docroot/core/lib/Drupal/Core/Session/SessionManager.php(164): Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start() #1 /.../docroot/core/lib/Drupal/Core/Session/SessionManager.php(195): Drupal\Core\Session\SessionManager->startNow() #2 /.../vendor/symfony/http-foundation/Session/Session.php(196): Drupal\Core\Session\SessionManager->save() #3 /.../docroot/core/lib/Drupal/Core/StackMiddleware/Session.php(60): Symfony\Component\HttpFoundation\Session\Session->save() #4 /.../docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #5 /.../docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #6 /.../docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #7 /.../docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #8 /.../docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #9 /.../vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #10 /.../docroot/core/lib/Drupal/Core/DrupalKernel.php(693): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #11 /.../docroot/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #12 {main}.
Severity	Error
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

abu-zakham created an issue. See original summary.

itaran’s picture

got the similar issue, this patch works for me

itaran’s picture

apaderno’s picture

Status: Active » Needs review
Spokje’s picture

Assigned: Unassigned » Spokje
FileSize
6.52 KB

Re-rolled patch #2 against latest Dev branch (the path of the files was incorrect, otherwise no code changes were made)

Spokje’s picture

Title: LogicException & RuntimeException on user login » LogicException & RuntimeException on user login and registration
Issue summary: View changes

Title/Summary update

Spokje’s picture

Assigned: Spokje » Unassigned
Status: Needs review » Reviewed & tested by the community
FileSize
48.97 KB
27.03 KB

I've tested patch #6.

I know I uploaded it myself, but it a re-roll of #2 with only the paths of the file to be patched corrected. No code changes were made between #6 and #2.

Screenshot (3068326-Watchdog_without_patch) shows the watchdog log on a site without patch #6 applied whilst:
(1) Registering a new user through Twitter
(2) Logging in with that new user through Twitter

The 2 Exceptions mentioned in the description of this issue are present.

Screenshot (3068326-Watchdog_with_patch) shows the watchdog log on a site with patch #6 applied whilst:
(1) Registering a new user through Twitter
(2) Logging in with that new user through Twitter

The 2 Exceptions mentioned in the description of this issue are gone. Logging in and registering through Twitter works as expected.

Marking as RTBC

Note: The Notice: Undefined property: stdClass::$email is fixed in this separate issue and should be ignored in this issue.

apaderno’s picture

Status: Reviewed & tested by the community » Needs review

The user who provided the patch shouldn't change the status to Reviewed & tested by the community. That is something a different user should do.

Spokje’s picture

Status: Needs review » Reviewed & tested by the community

@kiamlaluno I totally agree, but does this also apply when doing a simple re-roll of a patch created by another user?

As stated above: I didn't make any code changes, patch #2 doesn't apply because the path of the file-to-patch is incorrect (docroot/modules/contrib/social_auth_twitter/src/Controller/TwitterAuthController.php). I simply changed that to the correct path (a/src/Controller/TwitterAuthController.php) in my patch #6.
Since it's a reroll I couldn't add an interdiff, but that's the only change I've made.

Spokje’s picture

Status: Reviewed & tested by the community » Needs review

Oops, didn't mean to change the status back to RTBC, had an old browser window open...
Setting back to NR

Rajab Natshah’s picture

Title: LogicException & RuntimeException on user login and registration » Fix LogicException & RuntimeException on user login and registration
Rajab Natshah’s picture

Rajab Natshah’s picture

Priority: Major » Critical

Abdullah Yassin’s picture

Abdullah Yassin’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.