Backport of 5e12e892.
This fix is for issue #3206857, which is the 7.x-3.x version of issue #3206854.