Problem/Motivation
The jsonapi_include parser is by default enabled in src/EventSubscriber/ResponseSubscriber.php onResponse method:
...
$need_parse = TRUE; // Here: is default to TRUE.
if ($this->config->get('jsonapi_include.settings')->get('use_include_query')) {
$need_parse = !empty($event->getRequest()->query->get('jsonapi_include'));
}
if ($need_parse) {
...
And that policy is breaking jsonapi response when the module is enabled but the use_include_query config is not enabled, the module is working well when use_include_query config is enabled.
Steps to reproduce
Enable the module without enabling use_include_query on module configuration form.
Proposed resolution
By default set $need_parse to FALSE like so:
...
$need_parse = FALSE;
if ($this->config->get('jsonapi_include.settings')->get('use_include_query')) {
$need_parse = !empty($event->getRequest()->query->get('jsonapi_include'));
}
if ($need_parse) {
...
Comments
Comment #2
b.khouyComment #3
b.khouyComment #4
b.khouyComment #5
b.khouyComment #8
ptmkenny commentedThanks for this report. I agree this is a bug, but I think the issue is that the default config is never set. So I propose that we add a default config to this module.
Comment #9
ptmkenny commentedComment #10
ptmkenny commentedActually, can you provide more info about how the module breaks the response? This may be a documentation issue.
By default, when use_include_query is not enabled, all responses are parsed for includes. If use_include_query is enabled, only responses with the query string are parsed.
Comment #11
ptmkenny commentedI think this may just be an issue of bad documentation: https://www.drupal.org/project/jsonapi_include/issues/3271379
Please check the revised documentation/project page, and if this is still an issue, feel free to re-open.