Port the changes from contao/core@d4b319cc2f7b846d925611bfb4bddad69ccb1dc4