Fixes #19725. (cherry picked from commit 95599cac) (cherry picked from commit 1af2dba1) (cherry picked from commit 13426b78)