xp
xp copied to clipboard
js authLib.modifyProfile() stores array with single value as string
Enonic version: 6.9.2 OS: Mac OSX
When I store a JS object (might be a deep structure) in Enonic XP, I expect getting the exact same object back when I fetch it back from Enonic XP.
But that is not the case.
Any array within the structure which has a single value get stored as a string instead of an array with a single value.
For site-config, content-types, component config, etc we know which value should be an array, based on the xml file, and so we can use lib.util.data.forcearray to workaround the problem. But it's not pretty.
When it comes to undefined dynamic structures it is a bigger problem.
I guess I could workaround it by using JSON.stringify when I store data, and JSON.parse when I fetch data. Also not pretty.
I hope this gets fixed in Enonic XP 7.0
I've made enonify so one can at least diff against what enonic has "changed" upon storage. https://github.com/ComLock/enonic-js-utils/blob/main/src/storage/indexing/enonify.ts#L11
This seems to be general case for all single value arrays, not just authLib.modifyPrifile @ComLock , right?
I can't remember anything about something I reported 4 years ago :) If it is still reproduceable, take it from there?
This is a general case for all "array" fields: internally "everything" (except null) is stored as an array, but single value arrays returned as value itself
Yes, this is the forceArray problem.