Unit/System Tests PR-5.4-dev Pending

User tests: Successful: Unsuccessful:

avatar Harsh63870
Harsh63870
6 Mar 2026

Problem

When a custom field has the same name as a core article property (e.g. "images"),
the custom field value overwrites the core value in the API response, causing
core article images to return empty and the custom field to also go missing.

Root Cause

In prepareItem(), the code blindly assigned $item->{$field->name} without
checking if that property already existed as a core article property.

Fix

  • Check for name collision using property_exists($item, $field->name)
  • If collision detected, prefix the custom field key with cf_
  • Apply the same prefix logic consistently in displayList(), displayItem() and prepareItem()
  • Register the prefixed key in both fieldsToRenderItem and fieldsToRenderList

Result

  • Core images property is preserved as-is
  • Custom field named images appears as cf_images in the response
  • Both single item (/content/articles/{id}) and list (/content/articles) endpoints are fixed

Testing

Added Cypress test: keeps core article images when a custom field is named images

Fixes #47301

avatar Harsh63870 Harsh63870 - open - 6 Mar 2026
avatar Harsh63870 Harsh63870 - change - 6 Mar 2026
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 6 Mar 2026
Category JavaScript Unit Tests
avatar brianteeman
brianteeman - comment - 6 Mar 2026

custom fields are also available in many other components. this only addresses com_content

avatar Harsh63870
Harsh63870 - comment - 6 Mar 2026

Thanks for pointing that out.
you are right currently my fix only handles the issue in com_content I was mainly focused on the article endpoints and didn't think about the fact that custom fields are used in other components as well ... so it probably makes more sense to handle this at a more central level so every component using custom fields gets the fix.
Would it be better to move this logic somewhere like libraries/src/MVC/View/JsonApiView.php, or should it be handled through com_fields (maybe FieldsHelper)?
Happy to refactor the PR and make the solution global. Just wanted to know the preferred place for it.

avatar Harsh63870 Harsh63870 - change - 6 Mar 2026
Labels Added: Unit/System Tests PR-5.4-dev

Add a Comment

Login with GitHub to post a comment