Port the changes from contao/core@a65b054b4be5a9ace93348047b3449e22f1640e8