[ ] Checked the logs and have uploaded a log file and provided a link because I found something suspicious there. Please do not post the log file in the topic because very often something important is missing.
I’m submitting a…
[ ] Regression (a behavior that stopped working in a new release)
[x] Bug report
[ ] Performance issue
[ ] Documentation issue or request
Current behavior
If one defines language fallbacks for localizable arrays they are not applied - instead the array is returned empty.
Expected behavior
Language fallbacks are applied properly for arrays as well. I guess that the issue is likely caused by squidex not being able to know whether an array is unset or just empty. So in the end the issue (and maybe the solution as well?) could be similar to [SOLVED] Assets don't use language fallbacks. Unset should be the default. Squidex could alternatively also use the minItems validation value as an indicator for the default value. In our case we set it to 1 which was then violated by the empty array response without any warning.
Minimal reproduction of the problem
Define an array in a schema and make it localizable. Optionally set the minimum item count to 1 in the validation tab of the the array property.
Define two languages A and B. Make A the fallback for B.
Define entries for the array in the fallback language A.
Don’t define entries for the array in the second language B.
Make a request and set the language headers, so that they target language B. You’ll get an empty array, and not the contents defined for fallback language A.
Environment
[ ] Self hosted with docker
[ ] Self hosted with IIS
[ ] Self hosted with other version
[x] Cloud version
Version: latest Cloud version
Browser:
[ ] Chrome (desktop)
[ ] Chrome (Android)
[ ] Chrome (iOS)
[ ] Firefox
[ ] Safari (desktop)
[ ] Safari (iOS)
[ ] IE
[ ] Edge
Others:
I can DM requests and responses as needed.
The button is there, but it doesn’t seem to do anything (apart from showing the warning dialog). When I press it with language B selected I still get an empty array afterwards.
Would using the minimum item count validator as an indicator for an unset value work as a short term solution? Maybe that’s more straightforward to implement?
Not sure I understand: how can I implement that on my own without manually defining the fallbacks on client side and walking through the fallback languages upon receiving empty arrays? That would unnecessarily increase the number of requests against the Squidex API for certain languages. Or isn’t that what you mean?
Of course for now I can just make sure to always set the correct array contents for all defined languages and thus circumvent the fallback mechanism completely, but it can become error prone and cumbersome if many languages are involved.
Okay, yes, that would work - but I still don’t like the double amount of data transferred as well as the need to redefine the fallback languages and everything client side. Makes my inner engineer cry - no offense.
So I guess I’ll just tell our content editors that they need to add array items for all languages. It works fine btw if you pass a language not defined in squidex, then it will properly fall back to the master language and populate the array.
Would it be possible to make the minimum item count validator work for that case? Then I could enforce editors to set array items for all languages.
@Sebastian Oh, nice! What do I need to do to make it work in Squidex? Pressing the “X” for a language still results in an empty array instead of the fallback, so I guess there is something else I need to do? Or does it only apply to new content items?