Forward port of issue #19788 to 2.2.4.