Default value of the 'defaultLanguage' field for a page that is created programmatically

Hi all,

When executing the script below (considering an inexistent “Main.MyPage”), the author and date attributes are set as expected, however the “defaultLanguage” field is empty, while a default language is set at the wiki level in the XWikiPreferences object.

{{velocity}}
#set ($xdoc = $xwiki.getDocument('Main.MyPage'))
* Author: $xdoc.author
* Date: $xdoc.date
* Default language: $xdoc.defaultLanguage
{{/velocity}}

Is this behaviour implemented on purpose, or should it be considered as a bug? Following a discussion with @lucaa, I understand there might be underlying API breakage considerations?

Related links:

Cheers,

Stéphane

Yes changing that now would be an API breakage. And we definitely need to fix https://jira.xwiki.org/browse/XWIKI-15159 (which is very easy).

Note that having an empty default language is not a bug and this is the case for most o of the pages in XWiki Standard and extensions (those containing scripts for example) but in the context of the UI the configured default language is set by default because it was assumed that most users would create pages to enter actual content (and if not the user would be advanced enough to change the default language anyway).

1 Like