Port the changes from contao/core@2b31da79d73f29b9f238b41fe3f0a758b08b0347