Index: wp-includes/category.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- wp-includes/category.php	(revision 703d5bdc8deb17781e9c6d8f0dd7e2c6b6353885)
+++ wp-includes/category.php	(revision )
@@ -21,14 +21,12 @@
  *
  *     @type string $taxonomy Taxonomy to retrieve terms for. In this case, default 'category'.
  * }
- * @return array List of categories.
+ * @return array|WP_Error List of categories.
  */
 function get_categories( $args = '' ) {
 	$defaults = array( 'taxonomy' => 'category' );
 	$args = wp_parse_args( $args, $defaults );
 
-	$taxonomy = $args['taxonomy'];
-
 	/**
 	 * Filter the taxonomy used to retrieve terms when calling {@see get_categories()}.
 	 *
@@ -37,7 +35,7 @@
 	 * @param string $taxonomy Taxonomy to retrieve terms from.
 	 * @param array  $args     An array of arguments. See {@see get_terms()}.
 	 */
-	$taxonomy = apply_filters( 'get_categories_taxonomy', $taxonomy, $args );
+	$args['taxonomy'] = apply_filters( 'get_categories_taxonomy', $args['taxonomy'], $args );
 
 	// Back compat
 	if ( isset($args['type']) && 'link' == $args['type'] ) {
@@ -48,13 +46,17 @@
 				'<code>taxonomy => link_category</code>'
 			)
 		);
-		$taxonomy = $args['taxonomy'] = 'link_category';
+
+		$args['taxonomy'] = 'link_category';
 	}
 
-	$categories = (array) get_terms( $taxonomy, $args );
+	$categories = get_terms( $args );
 
-	foreach ( array_keys( $categories ) as $k )
+	if ( ! is_wp_error( $args['taxonomy'] ) ) {
+		foreach ( array_keys( $categories ) as $k ) {
-		_make_cat_compat( $categories[$k] );
+			_make_cat_compat( $categories[ $k ] );
+		}
+	}
 
 	return $categories;
 }
