Ticket #11737: 11737.diff

File 11737.diff, 548 bytes (added by nacin, 3 years ago)

I chose null here, but false or an empty string might make more sense.

Line 
1Index: category.php
2===================================================================
3--- category.php        (revision 12592)
4+++ category.php        (working copy)
5@@ -178,11 +178,13 @@
6  * @since 1.0.0
7  *
8  * @param int $cat_id Category ID
9- * @return string Category name
10+ * @return string|null Category name, or null if category doesn't exist.
11  */
12 function get_cat_name( $cat_id ) {
13        $cat_id = (int) $cat_id;
14        $category = &get_category( $cat_id );
15+       if ( ! $category || is_wp_error( $category ) )
16+               return null;
17        return $category->name;
18 }
19