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