Uploaded image for project: 'Magnolia REST Framework'
  1. Magnolia REST Framework
  2. MGNLREST-287

Unable To Get Secondary Language From Rest Response When Primary Language Is Blank

    XMLWordPrintable

Details

    Description

      When you create some i18n content and try to retrieve the data with rest calls containing language query parameters, the query will not return the appropriate language when the content using the fallbackLocale is left blank. This happens when the parameter is anything but the fallbackLocale's. 

      Steps to Reproduce
      1 - Create a simple endpoint to retrieve page nodes and all its accompanying information (you can use the endpoint I've attached).
      2 - Enable i18n on your site and include a fallbackLocale
      3 - Create a page (or use an existing page) and add some content for the language that is not the fallbackLocale.
      4 - Leave the content using the fallbackLocale empty
      5 - Try to retrieve the data you've made with rest calls making sure to specify a language in the query (See Additional Notes for examples)

      Actual Result
      When requesting a language other than the fallbackLocale, the response does not include the resulting property with its requested language although the property has it set.

      Expected Result
      The response returns the property requested with its specified language, even if the fallbackLocale version of the property is not set.

      Additional Notes / Examples
      Tested on 6.2.3 , 6.1.6 and 5.7.8.
      This can be reproduced on the demo. You can try by altering the title for the About app in different languages. Leave the "en" title blank and the "de" title with something. Then add an endpoint (you can add it within the Resources App in an already existing module such as within the path : /tours/restEndpoints/delivery)
      and try to invoke the rest call and specify a language. Here are some example calls :

      https://demoauthor.magnolia-cms.com/.rest/delivery/{your_endpoint}/travel/about?lang=all
      https://demoauthor.magnolia-cms.com/.rest/delivery/{your_endpoint}/travel/about?lang=en
      https://demoauthor.magnolia-cms.com/.rest/delivery/{your_endpoint}/travel/about?lang=de
      

      Let's say you set fallbackLocale to "en", then you will see that when you leave the content that uses "en" blank:
      "all" will return only de which is correct.
      "en" will not return anything which is also correct
      "de" will not return anything which is wrong

      Workarounds

      • Use "all" in your query then parse the response using some code.
      • Do not leave the fallbackLocale's content blank.

      Checklists

        Acceptance criteria

        Attachments

          Issue Links

            Activity

              People

                lam.nguyen Lam Nguyen Bao
                jnodarse Julian Nodarse
                Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:

                  Checklists

                    Bug DoR
                    Task DoD

                    Time Tracking

                      Estimated:
                      Original Estimate - Not Specified
                      Not Specified
                      Remaining:
                      Remaining Estimate - Not Specified
                      Not Specified
                      Logged:
                      Time Spent - 3.25d
                      3.25d