Commit 21b1b017 authored by larowlan's avatar larowlan

Issue #3053827 by gabesullice: Leaked cache metadata detected when using...

Issue #3053827 by gabesullice: Leaked cache metadata detected when using JSON:API to GET a threaded comment when RDF module is installed
parent 609bcb39
......@@ -953,4 +953,41 @@ public function testRecursionDetectedWhenResponseContainsViolationsFrom3042124()
$this->assertSame(sprintf('title: This value should not be null.'), $data['errors'][0]['detail']);
}
/**
* Ensure that child comments can be retrieved via JSON:API.
*/
public function testLeakedCacheMetadataViaRdfFromIssue3053827() {
$this->assertTrue($this->container->get('module_installer')->install(['comment', 'rdf'], TRUE), 'Installed modules.');
$this->addDefaultCommentField('node', 'article', 'comment', CommentItemInterface::OPEN, 'comment');
$this->rebuildAll();
// Create data.
Node::create([
'title' => 'Commented Node',
'type' => 'article',
])->save();
$default_values = [
'entity_id' => 1,
'entity_type' => 'node',
'field_name' => 'comment',
'status' => 1,
];
$parent = Comment::create(['subject' => 'Marlin'] + $default_values);
$parent->save();
$child = Comment::create(['subject' => 'Nemo', 'pid' => $parent->id()] + $default_values);
$child->save();
// Test.
$user = $this->drupalCreateUser(['access comments']);
$request_options = [
RequestOptions::AUTH => [
$user->getUsername(),
$user->pass_raw,
],
];
// Requesting the comment collection should succeed.
$response = $this->request('GET', Url::fromUri('internal:/jsonapi/comment/comment'), $request_options);
$this->assertSame(200, $response->getStatusCode());
}
}
......@@ -242,7 +242,7 @@ function rdf_comment_storage_load($comments) {
// bubbleable metadata, because it can be outside of a render context.
$comment->rdf_data['entity_uri'] = $entity->toUrl()->toString(TRUE)->getGeneratedUrl();
if ($comment->hasParentComment()) {
$comment->rdf_data['pid_uri'] = $comment->getParentComment()->toUrl()->toString();
$comment->rdf_data['pid_uri'] = $comment->getParentComment()->toUrl()->toString(TRUE)->getGeneratedUrl();
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment