[1.6.x] Fixed #22842

Backport of 7a1f8414c3b71b6af03e5be9f5f8db115551c410 from master.