Hi everyone,
while trying to fix XWIKI-24065 I noticed further discrepancies between the mandatory document initializer and the XWikiPreferences page in the XAR.
First, the plugins property is missing. I guess it should be added, too?
Second, the mandatory document initializer currently doesn’t set any custom displayers or also the picker or sort properties for ListClass. This has the consequence that they remain unset in the XClass definition and are only set when the XAR is imported. As we’re never updating this document from the XAR, this creates the following problems:
- New fields cannot have non-default values for
picker,sort, or custom displayers. - Existing values are never updated.
In particular the second one is very bad as it means that bug fixes including security fixes for custom displayers will never be applied.
I also discovered that just adding all non-default values now might create new problem in the future: What if we remove them again in a future version? This removal won’t be applied on an update. So we should probably explicitly set all values.
I have therefore the following proposal:
- Change this behavior and ensure that mandatory document initializers always create complete XClass definitions where all meta properties are set. This might have unintended consequences if another XClass exist both in a mandatory document initializer and a XAR or if an XClass has actually been customized.
- Change this behavior at least for XWikiPreferences to ensure that all users have the correct XClass definition, duplicate the display code in the mandatory document initializer and also initialize all other properties like
pickerandsort.
Note that while the code duplication is bad, I have a quite thorough page test now to catch any deviation between the XAR and the mandatory document initializer, and thanks to the fact that generating a bit more code is cheap with AI, it even produces a readable diff that shows the exact differences in case there are any: XWIKI-24065: underline property is not initialized automatically in XWikiPreferences for upgraded instances by michitux · Pull Request #5338 · xwiki/xwiki-platform · GitHub
Do you have any thoughts on this? I think we should also differentiate between the LTS branch and the master branch.
Thank you very much!