#25706 closed defect (bug) (fixed)
in_category() returns true if the first parameter is empty
| Reported by: | n.uddin.w | Owned by: | nacin |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.7.1 |
| Component: | Taxonomy | Version: | 3.7 |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
Description
in wp 3.7, in_category function returns true if the first parameter ($category) is an empty array or null.
in_category( $category, $_post )
Attachments (1)
Change History (13)
#2
@
13 years ago
- Component General → Taxonomy
- Keywords needs-patch added; has-patch removed
- Milestone Awaiting Review → 3.7.1
- Summary in_category function in wp 3.7 → in_category() returns true if the first parameter is empty
#3
@
13 years ago
This belongs to [25119]. There was an empty() check which is gone now.
has_tag() returns also true, but in 3.6 too. Should we add the empty() check to has_term() directly?
#4
follow-up:
↓ 6
@
13 years ago
has_tag() returns also true, but in 3.6 too.
Let's reduce the regression here and not cause any others. Did it return false at any point previously?
#6
in reply to: ↑ 4
@
13 years ago
Replying to nacin:
Did has_tag() return false at any point previously?
No, it hasn't since its inception in 3.1. The long description of the has_term() is spot on here - "If no terms are given, determines if post has any terms." since it uses is_object_in_term(), which has that logic built into it. And since every category always has at least one term, that's why we're seeing the true return in the OP's example.
Let's add the empty( $category ) check back into in_category() to fix the regression, and leave has_tag() as-is.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Could reproduce this.
3.6:
var_dump( in_category( '', 1177) ); // bool(false)3.7:
var_dump( in_category( '', 1177) ); // bool(true)