Rendering content too early PHP exception.

Created on 22 September 2022, over 2 years ago
Updated 31 July 2023, over 1 year ago

hi,

Problem/Motivation

My problem is if you create rest endpoint and try to load the url from a file via \Drupal::service('file_url_generator')->generateAbsoluteString() and you use a Drupal\rest\ResourceResponse as response.
you get the following error:

Uncaught PHP Exception 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\rest\ResourceResponse." at /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php line 154

Steps to reproduce

config:
      $schemes['s3'] = [
        'driver' => 's3',
        'config' => [
          'key' => '',
          'secret' => '',
          'region' => '',
          'bucket' => '',
          'endpoint' => "",
          'protocol' => "https",
          'cname_is_bucket' => FALSE,
          "cname" => "",
          'use_path_style_endpoint' => TRUE,
          'public' => FALSE,
          'options' => [
            'ACL' => 'private',
            '@http' => [
              'stream' => false,
            ]
          ]
        ],
        'cache' => TRUE,
        'serve_js' => TRUE,
        'serve_css' => TRUE,
      ];

Proposed resolution

The problem is more or less the same as in https://git.drupalcode.org/project/web_push_api/-/commit/40e8317231aaef6....

πŸ› Bug report
Status

Active

Version

2.1

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany marvin_B8

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

Merge Requests

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