Apply patch from RT 77693 / GH #556