Fixes #19652. (cherry picked from commit ffcd6838)
mentioned in commit f8cb5d4d
mentioned in commit ec52cddc