Port the changes from contao/core@fa81a2cdde6a96100ab008b128d55f20a164027e