Backport fix for #18923
This is a rebased and fixed version of !4409 (closed) which is itself a backport of !3497 (closed)
Fixes #18923 (closed)
This is a rebased and fixed version of !4409 (closed) which is itself a backport of !3497 (closed)
Fixes #18923 (closed)