Forward port of issue #20686 to 2.2.8.