Port the changes from contao/core@e0cfddca662fdf4305e5f2e580527f07f1a2bf95