[wp-trac] [WordPress Trac] #63488: Wrong return value for get_category_by_path()

WordPress Trac noreply at wordpress.org
Tue May 27 09:57:31 UTC 2025


#63488: Wrong return value for get_category_by_path()
--------------------------+------------------------------
 Reporter:  milana_cap    |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Taxonomy      |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:  docs
--------------------------+------------------------------
Description changed by milana_cap:

Old description:

> The function `get_category_by_path()`,
> [https://developer.wordpress.org/reference/functions/get_category_by_path/]
> claims to return `WP_Term|array|WP_Error|null` but it does not return the
> `WP_Error`.
>
> Testing:
>
> {{{#!php
> <?php
> $category = get_category_by_path( 'wrongpath' );
> if ( ! is_wp_error( $category ) ) {
>    echo 'not an error';
> }
> }}}
>
> I've got the string echoed for the non-existent category.
>
> I created a PR with a patch, but @harishtewari has reported it.
>
> Report: https://github.com/WordPress/Documentation-Issue-
> Tracker/issues/1908
> PR:

New description:

 The function `get_category_by_path()`,
 [https://developer.wordpress.org/reference/functions/get_category_by_path/]
 claims to return `WP_Term|array|WP_Error|null` but it does not return the
 `WP_Error`.

 Testing:

 {{{#!php
 <?php
 $category = get_category_by_path( 'wrongpath' );
 if ( ! is_wp_error( $category ) ) {
    echo 'not an error';
 }
 }}}

 I've got the string echoed for the non-existent category.

 I created a PR with a patch, but @harishtewari has reported it.

 Report: https://github.com/WordPress/Documentation-Issue-
 Tracker/issues/1908
 PR: https://github.com/WordPress/wordpress-develop/pull/8844

--

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/63488#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list