Port the changes from contao/core@5ef368987c7d560ddafd6c94793f81f765bd862d