Improve error handling in get_categories().
get_categories()
When passed an invalid 'taxonomy', get_terms() will return a WP_Error object. This object should not be blindly cast to an array. Instead, an empty array should be returned, to indicate that no matching terms have been found.
'taxonomy'
get_terms()
WP_Error
Props virgodesign, sebastian.pisula. Fixes #36227.