Problem/Motivation

I noticed the following errors in our tests which use EntityToJsonApi

/app/docroot/core/lib/Drupal/Core/EventSubscriber/RssResponseRelativeUrlFilter.php:24
stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated

/app/docroot/core/lib/Drupal/Core/EventSubscriber/ActiveLinkResponseFilter.php:85
stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated

Turns out the register basic HTTP kernel doesn't call \Drupal\Core\StackMiddleware\NegotiationMiddleware which is how Drupal registers content types. So all responses from the basic kernel have null as the content type.

That means because \Drupal\jsonapi\EventSubscriber\ResourceResponseSubscriber::renderResponseBody cannot set the content type properly:

      $response->setContent($serializer->encode($jsonapi_doc_object->getNormalization(), $format));
      $response->headers->set('Content-Type', $request->getMimeType($format));

Maybe it's a core bug and not here? But caused by this module's service.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mglaman created an issue. See original summary.

mglaman’s picture

Issue summary: View changes

mglaman’s picture

Status: Active » Needs review
bbrala’s picture

Took a while, but yes! :)

  • bbrala committed fa43690b on 8.x-3.x authored by mglaman
    fix: #3512041 http_kernel.basic doesn't register api_json format
    
    By:...
bbrala’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.