Port the changes from contao/core@78bf983b47f7fa290cbb7a0fd57e0efe9857ddea