[wp-trac] [WordPress Trac] #14892: minor improvement on category__in

WordPress Trac wp-trac at lists.automattic.com
Fri Sep 17 22:09:55 UTC 2010


#14892: minor improvement on category__in
-------------------------+--------------------------------------------------
 Reporter:  sboisvert    |       Owner:                 
     Type:  enhancement  |      Status:  new            
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Query        |     Version:  3.0.1          
 Severity:  minor        |    Keywords:  query          
-------------------------+--------------------------------------------------
Description changed by scribu:

Old description:

> if category__in is only provided an int, it will fail (relatively
> silently). I find this to be "not friendly"
>
> If I may suggest changing lines 1371-1372 in /wp-includes/query.php  to
> this:
> if ( !is_array($qv['category__in']) || empty($qv['category__in']) ) {
>         if (is_long($qv['category__in']) || is_int($qv['category__in'])){
>                 $qv['category__in'] = array($qv['category__in']);
>         } else{
>                 $qv['category__in'] = array();
>         }
>
> I would in the same vein implement the change for category__not_in
> if ( !is_array($qv['category__not_in']) || empty($qv['category__not_in'])
> ) {
>                                 if (is_long($qv['category__not_in']) ||
> is_int($qv['category__not_in'])){
>                                         $qv['category__not_in'] =
> array($qv['category__not_in']);
>                                 } else{
>                                         $qv['category__not_in'] =
> array();
>                                 }
>
> I would also suggest implementing for tag__in and etc etc

New description:

 if category__in is only provided an int, it will fail (relatively
 silently). I find this to be "not friendly"

 If I may suggest changing lines 1371-1372 in /wp-includes/query.php  to
 this:

 {{{
 if ( !is_array($qv['category__in']) || empty($qv['category__in']) ) {
         if (is_long($qv['category__in']) || is_int($qv['category__in'])){
                 $qv['category__in'] = array($qv['category__in']);
         } else{
                 $qv['category__in'] = array();
         }
 }}}

 I would in the same vein implement the change for category__not_in

 {{{
 if ( !is_array($qv['category__not_in']) || empty($qv['category__not_in'])
 ) {
                                 if (is_long($qv['category__not_in']) ||
 is_int($qv['category__not_in'])){
                                         $qv['category__not_in'] =
 array($qv['category__not_in']);
                                 } else{
                                         $qv['category__not_in'] = array();
                                 }
 }}}

 I would also suggest implementing for tag__in and etc etc

--

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/14892#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list