[1.7.x] Tweaked fix for refs #23946; thanks Claude.

Backport of 5c773447c3239a297b22929f0df15d2971d72e77 from master