`WP_UnitTestCase::go_to()` tried its best to clean up global space, but ultimately fell short. Because it was blowing away `WP` every time it was called, it was dropping all the query vars that were registered for custom taxonomies and custom post types (ouch).

Introduces `_cleanup_query_vars()`. This is a prerequisite for the unit tests on #20767. All unit tests pass with this change.

See #20767.
Fixes #25818.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25937 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Category and tag are typically checked before checking for a custom taxonomy. If the global query matches category or tag (even if it also has tax_query set), return category/tag as the queried object, instead of arbitrarily returning the first term in the `tax_query` stack (typically those added with 'pre_get_posts').

Real world example: http://www.emusic.com/17dots/topics/daily-download/ - "tag" page, regionalized for US-only content using `pre_get_posts` passing in the terms "US" and "ALL" for "region" (custom tax). All of the theme functions would output "ALL" as the term name. Even though it was a tag archive, the queried object was an arbitrary term from `tax_query`.

See [26006]. All unit tests pass.
Fixes #20767.



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


git-svn-id: http://core.svn.wordpress.org/trunk@25938 1a063a9b-81f0-0310-95a4-ce76da25c4cd
When WordPress is loaded in a function (e.g. unit tests) the variables initialized at the top level aren't globals, but we expect them to be. Explicitly make the version variables global.

Props nbachiyski.
Fixes #23685.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25939 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Don't globalize version variables twice. See #23685.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25940 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Cast proper fields to `int` when returning from `wp_get_object_terms()`. Add `term_taxonomy_id` and `object_id` to the list in `sanitize_term()` and `sanitize_term_field()`.  

Fixes #17646. Adds unit tests.
Props simonwheatley, dd32, kovshenin.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25941 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Pass `$args` to the `export_wp` action in `export_wp()`, which is currently passed no arguments.

Props nickdaugherty.
Fixes #25574.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25942 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Respect `paged` when `offset` is used in `WP_Query`. Adds unit tests.

Props coffee2code.
Fixes #18897.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25943 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Add a filter to the Background Updates debug email, matches the filter used on the non-debug post-update emails. Props pento. Fixes #25756

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


git-svn-id: http://core.svn.wordpress.org/trunk@25944 1a063a9b-81f0-0310-95a4-ce76da25c4cd
When checking filesystem permissions for core updates, only check the permissions of the files which we need to alter. Props nacin for initial patch. Fixes #25771 for trunk

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


git-svn-id: http://core.svn.wordpress.org/trunk@25945 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Remove dead code from the Plugin Upgrader class. Props jdgrimes. Fixes #25470

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


git-svn-id: http://core.svn.wordpress.org/trunk@25946 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Core Upgrader success statistics: Pass the version of WordPress we're upgrading from, as well as the version being upgraded to. Props nacin. See #25772 for trunk

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


git-svn-id: http://core.svn.wordpress.org/trunk@25947 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Core Upgrader: Include an unmodified $wp_version in Core_Upgrader::upgrade(). This protects against cases where the global $wp_version has been modified. See #25772

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


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