Fix/2.7.x/issue 7680

Here is a backport of the fix for Issue #7680 to the 2.7.x branch.