See https://github.com/xwiki/xwiki-platform/pull/2779/commits/d3e58ba38fc8d618a2086df2d05741de3a6657cf for some hints on the solution.