https://github.com/xwiki/xwiki-platform/pull/5368 applied on master (18.3.0RC1). Need to be cherry-picked on 17.10.x after 17.10.6 has been released.