Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#4069 closed defect (bug) (fixed)

query_posts('category_name=test') = database error

Reported by: devil1591 Owned by:
Milestone: 2.2 Priority: high
Severity: blocker Version: 2.2
Component: General Keywords:
Focuses: Cc:


If you make a

<?php query_posts('category_name=test'); ?>

before your loop, you will have this error

WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND rel_type = 'category' AND (post_type = 'post' AND (post_st]
SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts LEFT JOIN wp_post2cat ON (wp_posts.ID = wp_post2cat.post_id) LEFT JOIN wp_categories ON (wp_post2cat.category_id = wp_categories.cat_ID) WHERE 1=1 AND category_id IN () AND rel_type = 'category' AND (post_type = 'post' AND (post_status = 'publish' OR post_status = 'private')) GROUP BY wp_posts.ID ORDER BY post_date DESC LIMIT 0, 10

Tested on a fresh trunk install

Change History (2)

#1 @devil1591
11 years ago

precision: the category name "test" doesn't exist here, but if you put an existing category name, it won't found it and will return the same error because of the empty IN ()

#2 @markjaquith
11 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [5171]) Fix category_name=foo WP_Queries. fixes #4069

Note: See TracTickets for help on using tickets.