filefield_paths_process_string() which handles file's name & path to transformations makes use of token replacement.
In some case, token replacement leads to triggering some rendering. When this occurs in a "non-webpage" context, such as JSON:API or REST requests, this rendering create caching metadata which bubble up and is never catched/handled, leading to one of the most absconse/undebuggable error of a D8 project right now : the dreaded
"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"
I think filefield_paths_process_string() must wrap its logic in a render context to catch the generated metadata and handle it.
Comment | File | Size | Author |
---|---|---|---|
#2 | fieldfield_path-leaked_cache_metadata-3074642-2.patch | 6.13 KB | garphy |
Comments
Comment #2
garphy CreditAttribution: garphy at ICI LA LUNE commentedHere's a quick attempt to wrap the logic in a separate RenderContext and pop the generated metadata just before returning the result.
Comment #3
garphy CreditAttribution: garphy at ICI LA LUNE commentedComment #4
stefan.butura CreditAttribution: stefan.butura at Eau de Web commentedWorked fine for me. Thank you so much.