Port the changes from contao/core@49095d96f9a3c02907c870bbc5daa0704ab781fc