Port the changes from contao/core@bf19c2f0c7a0f4fd9de5afd12e0eafb19c3513c7