Note that this bug is still happening even after XWIKI-21848. We would need a proper implementation of XWIKI-21993 with what's discussed on the forum to solve that.