Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#31526 closed defect (bug) (fixed)

Correct PHPDoc description for get_terms()::$args['number']

Reported by: iandunn's profile iandunn Owned by: drewapicture's profile DrewAPicture
Milestone: 4.2 Priority: normal
Severity: minor Version: 4.1
Component: Taxonomy Keywords: has-patch
Focuses: docs Cc:


The documentation says that -1 will return all terms, and that -1 is the default, but the default is actually an empty string, which gets converted to 0.

Passing 0 returns all terms, but -1 gets converted to 1, leading to unexpected results.

Attachments (1)

31526.diff (1.2 KB) - added by iandunn 9 years ago.

Download all attachments as: .zip

Change History (6)

9 years ago

#1 @iandunn
9 years ago

  • Keywords has-patch added
  • Severity changed from normal to minor

#2 @DrewAPicture
9 years ago

  • Milestone changed from Awaiting Review to 4.2
  • Owner set to DrewAPicture
  • Status changed from new to reviewing
  • Version changed from trunk to 4.1

Hi Ian,

Thanks for the patch. I'll take a look and get this fixed.

Introduced in [29128].

#3 @DrewAPicture
9 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 31638:

Correct the $number argument description in get_terms() to reflect that an empty string or 0 will return all possible results, not -1.

Previously, it was noted that -1 would return all possible results. However, as the value of $number is passed through absint(), -1 would actually be converted to 1, thereby producing unexpected results.

Props iandunn.
Fixes #31526.

#4 @iandunn
9 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

It looks like r31638 added Default ''|0 (all) twice.

#5 @DrewAPicture
9 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 31652:

Remove a duplicate mention of the default value for the $number argument in get_terms().

Props iandunn.
Fixes #31526.

Note: See TracTickets for help on using tickets.