Problem/Motivation
When responding to a GET request for a comment entity with a parent comment Drupal detects leaked cache metadata. Causing the following error:
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\\jsonapi\\ResourceResponse.
This is caused by the rdf module in core/modules/rdf/rdf.module:L244-246:
if ($comment->hasParentComment()) {
$comment->rdf_data['pid_uri'] = $comment->getParentComment()->toUrl()->toString();
}
The lines above it have already been corrected in #2631774: Impossible to update Comment entity with REST (HTTP PATCH): bundle field not allowed to be updated, but EntityNormalizer::denormalize() requires it to:
// The current function is a storage level hook, so avoid to bubble
// bubbleable metadata, because it can be outside of a render context.
$comment->rdf_data['entity_uri'] = $entity->toUrl()->toString(TRUE)->getGeneratedUrl();
Presumably, this was simply overlooked and the same error is also present in the REST module.
Proposed resolution
Use the same fix as #2631774 did for the remaining lines in rdf_comment_storage_load.
Remaining tasks
Regression test
Patch
Review
Commit
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 3053827-9.patch | 2.56 KB | gabesullice |
| #2 | 3053827-2-combined.patch | 2.52 KB | gabesullice |
| #2 | 3053827-2-fix.patch | 670 bytes | gabesullice |
| #2 | 3053827-2-test-only.patch | 1.87 KB | gabesullice |
Comments
Comment #2
gabesulliceComment #3
gabesulliceComment #4
gabesulliceComment #6
wim leersWow, nice catch! 👏
Nit: "viaRdf" should be changed to something else :)Nope, this is correct, because it's caused by the RDF module 😮Comment #7
wim leersComment #8
alexpottNeeds a reroll.
Comment #9
gabesulliceRerolled.
Comment #11
larowlannit:I don't think we need this comment, git blame will tell us the issue, we don't normally reference closed issues in the code - so I removed on commit
There are a lot of existing ones in that test class from before the module came to core, can you open a follow-up to remove them?
Thanks
Committed 21b1b01 and pushed to 8.8.x. Thanks!
c/p as b25d3ca0a6 and pushed to 8.7.x
Comment #13
wim leersThat’s a pattern I established to make it easier to correlate regressions with d.o issues. I know it’s a new pattern, but core actually does this too in
BigPipeRegressionTest.Note that removing those lines you asked to be removed won’t have git histories pointing to issues, since JSON:API commit history wasn’t brought into Drupal Core.