Port the changes from contao/core@3ff31cd007b8837fc61dbd4c63d3f112c6290adf