Port the changes from contao/core@cb9f2e131355b2ccbf2547bf03de891c7466f9ad