Fix a regression for `get_queried_object()` by checking for `category_name` when `cat` isn't set - mainly `is_category()` being true for Uncategorized or when queried object is accessed in `pre_get_posts`. Also check for `$query['terms']` when trying to assign a term as the queried object when `is_tax()` is true. Adds a unit test. See [26007] for how I originally broke this while fixing a bigger issue.

Props Chouby, jeremyfelt.
Fixes #26634, #26627.



git-svn-id: https://develop.svn.wordpress.org/trunk@26864 602fd350-edb4-49c9-b593-d223f7449a82