﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc
15959	get_adjacent_post() can generate invalid SQL	dd32	westi	"As reported on wp-testers, if get_adjacent_post() is used with `$in_same_cat = true` on a post type which does not support categories, then a invalid SQL will be generated.

eg:
{{{
SELECT p.* FROM wp_posts AS p INNER JOIN wp_term_relationships AS tr ON p.ID = tr.object_id INNER JOIN wp_term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id AND tt.taxonomy = 'category' AND tt.term_id IN () WHERE p.post_date < '2010-07-04 12:24:53' AND p.post_type = 'note' AND p.post_status = 'publish' AND tt.taxonomy = 'category' ORDER BY p.post_date DESC LIMIT 1
}}}
specifically
{{{
AND tt.term_id IN ()
}}}

Whilst this is not a problem in the 2011 theme, Some themes may call the functions which can result in this.

wp-testers thread: http://lists.automattic.com/pipermail/wp-testers/2010-December/013841.html

one potential solution would be:
{{{
	// Check to see if the Post Type supports categories before honoring the argument.
	if ( $in_same_cat ) {
		$taxonomies = get_object_taxonomies($post);
		if ( ! in_array('category', $taxonomies) )
			$in_same_cat = false;
	}
}}}

From what I can see, this would not be a regression from any previous version of WordPress"	defect (bug)	closed	normal	3.5	Query	3.0	normal	fixed	has-patch needs-testing	batmoo@…
