Forward port of issue #46584 to 3.5.x.
Forward port of issue #46584 to 3.5.x.