PR-4.4-dev Pending

User tests: Successful: Unsuccessful:

avatar rubenferreira97
rubenferreira97
21 Jun 2024

Pull Request for Issue #43641.

Summary of Changes

JsonDocument in Joomla 4.4.5 wrongly sets text/plain to all browsers (tested on Edge, Firefox and Chrome). Browsers do not usually send application/json, instead they send */* with some lower priority.

Note: Joomla 5 already fixed this, so this change needs to be merged to Joomla 4 (maybe Joomla 4.4.6?).

Testing Instructions

Ping and API endpoint that extends JsonDocument. In my case I am returning a normal json response instead of a json:api.

Actual result BEFORE applying this Pull Request

Ping an API endpoint like localhost/api/index.php/v1/example:
Content-Type: text/plain; charset=utf-8

Expected result AFTER applying this Pull Request

Ping an API endpoint like localhost/api/index.php/v1/example:
Content-Type: application/json; charset=utf-8

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

avatar rubenferreira97 rubenferreira97 - open - 21 Jun 2024
avatar rubenferreira97 rubenferreira97 - change - 21 Jun 2024
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 21 Jun 2024
Category Libraries
avatar rubenferreira97 rubenferreira97 - change - 21 Jun 2024
Title
Fix `content-type` header to `application/json
Fix `content-type` header to `application/json`
avatar rubenferreira97 rubenferreira97 - edited - 21 Jun 2024
avatar rubenferreira97 rubenferreira97 - change - 21 Jun 2024
The description was changed
avatar rubenferreira97 rubenferreira97 - edited - 21 Jun 2024
avatar rubenferreira97 rubenferreira97 - edited - 21 Jun 2024
avatar rubenferreira97 rubenferreira97 - change - 21 Jun 2024
The description was changed
avatar rubenferreira97 rubenferreira97 - edited - 21 Jun 2024
avatar rubenferreira97 rubenferreira97 - change - 21 Jun 2024
The description was changed
avatar rubenferreira97 rubenferreira97 - edited - 21 Jun 2024
avatar rubenferreira97 rubenferreira97 - change - 21 Jun 2024
The description was changed
avatar rubenferreira97 rubenferreira97 - edited - 21 Jun 2024
avatar rubenferreira97 rubenferreira97 - edited - 21 Jun 2024
avatar laoneo
laoneo - comment - 21 Jun 2024

Can you reference the pr which fixed this issue already in 5. The change here is a BC break, so not sure if the need to fix it weight's higher than the BC policy.

avatar rubenferreira97
rubenferreira97 - comment - 21 Jun 2024

@laoneo The PR which fixed this issue was #39397. IMO this is a bug that should be fixed since JsonDocument should always return application/json by default. Even the IE9 fix was a hacky workaround. Don't know about Joomla BC policy, but are people really expecting this and working around this behavior?

avatar laoneo
laoneo - comment - 21 Jun 2024

Problem is that this behavior did exist now for a long time. Changing it in a patch release might cause unexpected issues in extensions using that class as it belongs to the public API. We will discuss it in maintainers group and report back.

avatar HLeithner HLeithner - change - 15 Nov 2024
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2024-11-15 13:47:33
Closed_By HLeithner
Labels Added: PR-4.4-dev
avatar HLeithner HLeithner - close - 15 Nov 2024
avatar HLeithner
HLeithner - comment - 15 Nov 2024

Closing this PR, since 4.4 is in security mode only and it's fixed in 5.x

Add a Comment

Login with GitHub to post a comment