I created a PR at https://github.com/xwiki/xwiki-platform/pull/6331 because I'm not fully sure about the fix.