Opened 16 years ago
Closed 16 years ago
#10053 closed defect (bug) (fixed)
get_children() returns false when no children are found
Reported by: | Denis-de-Bernardy | Owned by: | ryan |
---|---|---|---|
Milestone: | 2.9 | Priority: | normal |
Severity: | minor | Version: | 2.7 |
Component: | Query | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
It should return an empty array instead.
Attachments (2)
Change History (13)
#3
@
16 years ago
- Summary changed from get_children() returns null when no posts are found to get_children() returns false when no children are found
#4
@
16 years ago
- Keywords has-patch added
so, basically, the patch makes it return a variable initialized to array() instead of false. checked the WP code, and it's not expecting a value of false anywhere.
this makes the behavior of get_children() consistent with that of get_posts()
#7
@
16 years ago
By the way, doesn't get_posts() also return false when no posts are found? We should be consistent about this.
You usually have to do something different when you don't find any items, and it's easier to check if ( $children ) than if ( empty($children) ).
#8
@
16 years ago
It can definitely wait, yes. :-)
(bool) array() returns false and is faster than empty(array()).
#10
@
16 years ago
- Keywords commit added
uploading a slightly improved patch in a sec. it is harmless for WP. on the contrary, it:
- actually enhances get_media_items()
- prevents a potential warning in adjacent_image_link()
- prevents a potential warning in get_children() itself (false is constant, rather than a reference to a variable)
Found while doing the following query in the loop: