This is a fix to the wrong behavior that 15c3906eeb introduced. Backport of 4befef9 from trunk.
15c3906eeb
4befef9