WordPress.org

Make WordPress Core

Opened 4 months ago

Last modified 4 months ago

#43345 reviewing defect (bug)

term_exists() may return 0 which is not a text-documented return type

Reported by: dotancohen Owned by: johnbillion
Milestone: 5.0 Priority: normal
Severity: normal Version: 4.9.4
Component: Taxonomy Keywords: has-patch needs-testing
Focuses: Cc:

Description

The PHPDoc for term_exists() reads as follows:

Returns null if the term does not exist. Returns the term ID if no taxonomy is specified and the term ID exists. Returns an array of the term ID and the term taxonomy ID the taxonomy is specified and the pairing exists.

Despite this, under some conditions ($term===0) the method return int 0. The attached patch rectifies this to return null, and additionally updates the @return tag datatype from mixed to string|array|null for better IDE support.

Attachments (1)

43345.diff (1.5 KB) - added by dotancohen 4 months ago.
Patch to resolve issue.

Download all attachments as: .zip

Change History (2)

@dotancohen
4 months ago

Patch to resolve issue.

#1 @johnbillion
4 months ago

  • Keywords has-patch needs-testing added
  • Milestone changed from Awaiting Review to 5.0
  • Owner set to johnbillion
  • Status changed from new to reviewing
  • Type changed from enhancement to defect (bug)
Note: See TracTickets for help on using tickets.