Port the changes from contao/core@4ba608031d986fc8c1bb2ed0f4a7e440ee35bfa5