Forward port of issue #19702 to 2.3.1.