Port the changes from contao/core@40a0963fe5552fab3bbc37f022c11fd14f5ee74a