PHP LogicException when processing Recurly webhooks that results in token replacement

Created on 15 May 2023, over 1 year ago
Updated 16 May 2023, over 1 year ago

Problem/Motivation

Whenever Recurly sends a webhook we return an HtmlResponse(). This can result in an error like the following if your configuration uses tokens that that require rendering to populate fields in Drupal based on data received from Recurly.

Example error:

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.

This is related to this change: https://www.drupal.org/node/2513810 β†’

What happens is \Drupal\recurly\RecurlyEntityOperations::entityUpdate gets called, and depending on configuration, calls \Drupal::token()->replace() ... which can cause "early rendering".

It seems that one solution is to return a Symfony\Component\HttpFoundation\Response instead of a Drupal\Core\Render\HtmlResponse. Which in this case should be fine because we're just returning some basic text, and a status code, and don't need to actually respond with valid HTML.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

4.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States eojthebrave Minneapolis, MN

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

Comments & Activities

Production build 0.71.5 2024