[MGNLREST-325] Retrieving localized content via multi composite field using the .rest endpoint is not correct Created: 12/Aug/21  Updated: 26/Aug/21  Resolved: 26/Aug/21

Status: Closed
Project: Magnolia REST Framework
Component/s: None
Affects Version/s: 2.2.8
Fix Version/s: None

Type: Bug Priority: Neutral
Reporter: Oanh Thai Hoang Assignee: Unassigned
Resolution: Not an issue Votes: 0
Labels: VN-Analysis
Remaining Estimate: 0.5h
Time Spent: 3.5h
Original Estimate: Not Specified

Attachments: PNG File de-dialog.png     PNG File en-dialog.png     PNG File jcr-structure.png     PNG File lang-all-get-correctly.png     PNG File lang-de-get-incorrectly.png     PNG File lang-en-get-correctly.png     Zip Archive test.zip    
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

Have jcrMultiField which are enable i18n = true like below:

form:
  properties:
    title:
      i18n: true
      $type: textField
    addresses:
      label: Addresses
      i18n: true
      $type: jcrMultiField
      itemProvider:
        $type: currentItemProvider
      field:
        $type: compositeField
        properties:
          street:
            label: Street name
            $type: textField 

Steps to reproduce

  1. Create one page from "test" template. See my light dev  test.zip
  2. Add 3 value for addresses fields in english form. See 
  3. Add 2 value for addresses fields in german form. See 
  4. Observe 5 address node in JCR browser. See 
  5. Call rest pages rest endpoint config in test light-dev. 
  6. Retrieve lang = all, and lang = en correctly. See   
  7. Retrieve lang = de incorrectly. See the red one is wrong 

.. Logs, screenshots, gifs...

Expected results

Retrieve lang = de correctly. It means retrieve list [addresses0, addresses1] only 

Actual results

Retrieve lang = de incorrectly. See [addresses0, addresses1, addresses2]

Workaround

Development notes



 Comments   
Comment by Mikaël Geljić [ 26/Aug/21 ]

With i18n: false on subfields, we would have the same problem. That's precisely what I was afraid of. The reason is: i18n node-wrappers try to find suffixed nodes/properties first, and if there's none, they fallback to unsuffixed content (from the default/fallback language).

Imagine that we have 2 composite fields instead of the multifield, one with i18n and one without. We would end up with nodes like foo, foo_de (i18n), and bar (no i18n). In this case, this behavior from node-wrappers is correct.

This is why in content-types, for multi-submodel (composite) properties, we generate an intermediate node, e.g. products, products_de, and then plain indexed nodes underneath: 00, 01, 02...

Generated at Mon Feb 12 06:58:48 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.