Port the changes from contao/core@866b0448e473d07ad7052fa4ec60c832629b3b0a