Regression in 2d38eb0ab9f78d68c083a5b78b1eca39027b279a Backport of 29c126bb349526b5f1cd78facbe9f25906f18563 from master