Port the changes from contao/core@5ea0c0514ae56110739f4c5fe2ef799424d1941d