WordPress.org

Make WordPress Core

Opened 9 years ago

Last modified 9 years ago

#14892 closed enhancement

minor improvement on category__in — at Version 3

Reported by: sboisvert Owned by:
Milestone: 3.1 Priority: normal
Severity: minor Version: 3.1
Component: Query Keywords:
Focuses: Cc:
PR Number:

Description (last modified by scribu)

if categoryin 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 categorynot_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 tagin and etc etc

Change History (3)

#1 @nacin
9 years ago

We can just cast it to an array, then run absint() on it using array_map().

#2 @sboisvert
9 years ago

That would be even better! Thank you.

#3 @scribu
9 years ago

  • Description modified (diff)
Note: See TracTickets for help on using tickets.