Fix lingering reference problem in `wp_get_object_terms()` by not setting the `foreach`'d vars to a reference. Adds unit test.

Props stephenharris.
Fixes #26339.


Built from https://develop.svn.wordpress.org/trunk@26510


git-svn-id: http://core.svn.wordpress.org/trunk@26404 1a063a9b-81f0-0310-95a4-ce76da25c4cd