Refs #20739. Thanks Raphaël Hertzog for the report and the initial patch. Backport of 3a44e2000 from master.