JSON:API include parser should be disabled by default (V1.7)

Created on 1 December 2023, 7 months ago
Updated 2 December 2023, 7 months ago

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) {
...
πŸ“Œ Task
Status

Needs review

Version

1.7

Component

Code

Created by

πŸ‡²πŸ‡¦Morocco b.khouy πŸ‡²πŸ‡¦ Morocco

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024