Port the changes from contao/core@ebf7a0c651cb73fe20dc1172b9c3dc93bec6767f