Make WordPress Core

Opened 11 months ago

Last modified 3 days 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.2 Priority: normal
Severity: normal Version: 4.9.4
Component: Taxonomy Keywords: has-patch needs-testing dev-feedback
Focuses: Cc:


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 11 months ago.
Patch to resolve issue.

Download all attachments as: .zip

Change History (4)

11 months ago

Patch to resolve issue.

#1 @johnbillion
11 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)

#2 @johnbillion
3 months ago

  • Milestone changed from 5.0 to 5.1

#3 @pento
3 days ago

  • Keywords dev-feedback added
  • Milestone changed from 5.1 to 5.2

This patch needs to be reviewed for side effects of changing the return value.

Note: See TracTickets for help on using tickets.