Fixes #19725. (cherry picked from commit 95599cac) (cherry picked from commit 1af2dba1)
mentioned in commit 97028786