Port the changes from contao/core@14998e783797ef1a340ded82c42b5b67daf4887b