don't mutate hash with fetch

Backports commits rails/rails@7171111 and rails/rails@269424b.