Follow-up for d4488889 and ca121e20. Fixes #17568. (cherry picked from commit 0f82a2ab) (cherry picked from commit dcff070d)