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