Port the changes from contao/core@1638f0961a5aebf3e82a1dbc3cc46e35cbf2df27