Port the changes from contao/core@c387639b821da4fc0b9617cb86f541e46a7dfc2e