Port the changes from contao/core@66814dd2b6b76dc0acc65df0ea625f2d30376742