Port the changes from contao/core@8a867380108660276ad3563f3c9fac8c262cd2fe