Bugfix 12358

Taking the appropriate commit from 6.7 which had already fixed it