EditorFileReference filter only adds cache tags for referenced files, not contexts + max-age

Created on 16 August 2021, almost 3 years ago
Updated 8 March 2024, 3 months ago

Problem/Motivation

Cache metadata on file entities, that have been uploaded through the text editor, are not bubbling up to the containing node.

I came across this issue whilst working on ✨ Add support for private uploads / presigned URLs Postponed . Our S3 image urls have a signature that expires after a certain amount of time, so we are setting a max-age on the file entity. This however is not working for images uploaded through the texteditor, resulting in expired url signatures and 403s on images.

Steps to reproduce

1) Enable image uploads in one of your text editor settings.
2) Set a max-age on the file entity of 60 seconds (do some logic that changes every 60 minutes, such as dynamically changing url parameters).
3) View the rendered node with render caching enabled
4) Wait 60 seconds

Expected result:
The cache for the file entity + node should regenerate

Actual result:
The previous cache is used.

Proposed resolution

Set the file as a cacheable dependency of the render array.

Remaining tasks

  • Fix this in code.
  • Write tests

User interface changes

n/a

API changes

n/a

Data model changes

n/a

Release notes snippet

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component
EditorΒ  β†’

Last updated 15 days ago

Created by

πŸ‡¬πŸ‡§United Kingdom Leon Kessler

Live updates comments and jobs are added and updated live.
  • Contributed project blocker

    It denotes an issue that prevents porting of a contributed project to the stable version of Drupal due to missing APIs, regressions, and so on.

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.

  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    This bug is still relevant.

    The thing is though that File entities in Drupal core have no cache contexts or max-age specified, which is why this went unnoticed.

Production build 0.69.0 2024