Fixes #12623. (cherry picked from commit 9de8a425)
mentioned in commit fb1bfd68
mentioned in commit a13aeadd