Port the changes from contao/core@7f9b619a96e8dbce67e5ac405f5bf2b27fd0c557