Forward port of issue #19202 to 2.2.5.