Port the changes from contao/core@fc37354ff146b3ba05c39ad0c1fe2e7b35f9258c