Use the main wiki descriptor server field for the domain name even in path based mode

Hi devs,

Right now the server field in the wiki descriptor has a different meaning depending if we are in path based or domain based mode:

  • domain based: the domain name of the URL
  • path based: the alias used to indicate the target wiki in the path

This means there is only two way to know the domain name for external URL in path based mode:

  • the URL of the first request
  • the property xwiki.home in xwiki.cfg file

This also means there is no way to indicate the domain at wiki level contrary to domain based for which you can use the descriptor.

Since the alias is never used for the main wiki I propose (initially suggested by @gdelhumeau) to change the meaning of the server field in the main wiki to indicate the domain to use when generating the external URLs no matter the mode.

In term of retro compatibility it means that if an instance in path based has crap in the main wiki descriptor (it’s possible since it’s totally useless right now) and upgrade it might end up with broken external URL (until the main wiki descriptor is fixed) produced by background threads like schedulers and mails. Something that reduce the likelihood of this happening is that the main wiki descriptor is automatically created when it does not exist and the domain of the input URL (which has a good chance of being the good) is set in it.

A possible alternative (which could also be done even if solution A is chosen) is to get rid of path based vs domain based mode and instead have two fields in the wiki descriptor: the domain and the alias. Then having some logic more or less similar to this:

  • if the domain is set in the current wiki descriptor then use it, if not fallback on main wiki descriptor, then first request
  • if the alias is set then generate a path based style URL path


Here is my +1 to change the meaning of server field in the main wiki descriptor.

So if I understand the goal is to change the logic so that to compute the domain (in both modes) we would use the following logic (in this order):

  • Check the server field in the current wiki
  • If not set, check the server field in the main wiki
  • If not set (is that possible, since you said there’s always a main wiki descriptor created? Maybe if the user cleared it?), then fallback on the value of the xwiki.home property
  • If not set, fallback on the domain name used in the first request



No, the proposal is only related to the main wiki descriptor, in subwikis this field is used to indicate the alias.

Right now to find the domain in path based mode we try:

  • xwiki.cfg xwiki.home property
  • then use the first request

So the idea is to insert a “look at main wiki descriptor step”.

FYI, my use-case is to be able to change the external URL without restarting XWiki. So editing xwiki.cfg is not an option, since it requires a restart.

+1 on my side.

With a warning: if the descriptor contains “localhost” (I remember having seen this default value from time to time), it could be considered as not set.

+1 for (pros, IMO):

  • minimizing the need to rely on the URL of the firs request which can be a nightmare (highly unreliable and sometimes hard to debug) when you’re monitoring and auto-restarting your XWiki instance in case of failures, like using xinit
  • minimizing the downtime of your instance by not having to restart when changing your external domain
  • making consistent the main wiki descriptor handling, regardless if domain or path based mode is enabled

It looks cleaner to me, but I don’t have any idea on the impact for doing it. So I’m +0 for solution A for now.


So we have:
Thomas: +1
Guillaume: +1
Edy: +1
Marius: +1
Simon: +0

So I think we could implement it now :slight_smile:

OK OK taking care of it today :slight_smile: