Make WordPress Core

Ticket #25429: 25429.2.diff

File 25429.2.diff, 1018 bytes (added by SergeyBiryukov, 13 years ago)
  • src/wp-includes/category.php

     
    7676 * @param int|object $category Category ID or Category row object
    7777 * @param string $output Optional. Constant OBJECT, ARRAY_A, or ARRAY_N
    7878 * @param string $filter Optional. Default is raw or no WordPress defined filter will applied.
    79  * @return mixed Category data in type defined by $output parameter.
     79 * @return object|array|WP_Error Category data in type defined by $output parameter. WP_Error if $category does not exist.
    8080 */
    8181function get_category( $category, $output = OBJECT, $filter = 'raw' ) {
    8282        $category = get_term( $category, 'category', $output, $filter );
     83
    8384        if ( is_wp_error( $category ) )
    8485                return $category;
    8586
     87        if ( null === $category )
     88                return new WP_Error( 'invalid_category', __( 'Invalid category' ) );
     89
    8690        _make_cat_compat( $category );
    8791
    8892        return $category;