Fixes #4108: Move r27423 to the 1.7 branch

---svn-pre-commit-ignore-below---

r27423 [[BR]]
Reorder the loop index.