Port the changes from contao/core@c9e00c8c55c5e797ffd0e02d3a28c45ec545f5c1