LogicException when logging out while masquerading

Created on 28 May 2024, about 1 month ago

Problem/Motivation

Steps to reproduce

Visit /user/logout while masquerading.

LogicException: The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Ensure you are not rendering content too early. Returned object class: Drupal\Core\Routing\TrustedRedirectResponse. in Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (line 154 of .../web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php).

The cause is this code in MasqueradeLogLogger::log():

      // For loggers that are not supporting HTML markup (e.g Syslog), the <p>
      // tag will be stripped out but we ensure a leading space, so that there's
      // still a delimiter from the main message.
      $path = Url::fromRoute('user.page')->toString();

Proposed resolution

Replace with:

      // For loggers that are not supporting HTML markup (e.g Syslog), the <p>
      // tag will be stripped out but we ensure a leading space, so that there's
      // still a delimiter from the main message.
      $path = Url::fromRoute('user.page')->toString(TRUE)->getGeneratedUrl();

See https://drupal.stackexchange.com/a/187094

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

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

Merge Requests

Comments & Activities

Production build 0.69.0 2024