#25706 closed defect (bug) (fixed)
in_category() returns true if the first parameter is empty
Reported by: | n.uddin.w | Owned by: | nacin |
---|---|---|---|
Milestone: | 3.7.1 | Priority: | normal |
Severity: | normal | Version: | 3.7 |
Component: | Taxonomy | Keywords: | |
Focuses: | Cc: |
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
@
11 years ago
- Component changed from General to Taxonomy
- Keywords needs-patch added; has-patch removed
- Milestone changed from Awaiting Review to 3.7.1
- Summary changed from in_category function in wp 3.7 to in_category() returns true if the first parameter is empty
#3
@
11 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
@
11 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
@
11 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.
#8
@
11 years ago
- brings back the empty() check in in_category()
- adds a test for passing falsy values to in_category() which should return false, as well as testing for a positive result.
Could reproduce this.
3.6:
var_dump( in_category( '', 1177) ); // bool(false)
3.7:
var_dump( in_category( '', 1177) ); // bool(true)