make a functional equivalent patch to fix #18632