- π¨π¦Canada dstorozhuk Chicago πΊπΈ, Toronto π¨π¦, Kyiv πΊπ¦
I don't think this issue is valid any more in 3.x.
Can anyone test it again?
So this isn't a direct bug bug, but a bug having to do with another module.
If you use this module along with the drupal core jsonapi module and you POST to the jsonapi, then one line of code causes issue.
To reproduce:
Enable this module
Enable the jsonapi module
Go to: /admin/config/services/jsonapi and then click on the radio button "Accept all JSON:API create, read, update, and delete operations." and save it.
From a tool like Postman now POST to drupal to create a new page.
EX:
POST http://drupallocal.com/jsonapi/node/article
(Body)
{
"data": {
"type": "node--article",
"attributes": {
"title": "TEST 1 PAGE"
}
}
}
And Drupal will throw the following error:
Uncaught PHP Exception 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. Returned object class: Drupal\\jsonapi\\ResourceResponse."
The stack trace goes back to line
views_url_alias_node.module file line 108
$alias = $entity->toUrl()->toString();
This is because the drupal ->toUrl() call triggers early rendering. (For more info on that read this article https://www.lullabot.com/articles/early-rendering-a-lesson-in-debugging-...)
The fix is to get the Url this way instead:
$alias = \Drupal::service('path.alias_manager')->getAliasByPath('/node/'.$entity->id());
And it returns the exact same thing as your line of code, only it won't trigger the early rendering (which the JSONAPI makes a fuss about).
(heres more info on issue
https://www.drupal.org/project/drupal/issues/3093471 β
)
Needs review
3.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
I don't think this issue is valid any more in 3.x.
Can anyone test it again?