WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 2 years ago

#20860 closed defect (bug) (duplicate)

Multiple Query String on URL Damage the Page

Reported by: arieputranto Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.4
Component: Query Keywords:
Focuses: Cc:

Description

Since the page generated by WP_Query from the query variables from the URL, I tried to add multiple query string on an URL like this:

http://localhost/?cat=1&author=1

For what I've been testing, it's resulting TRUE to both $wp_query->is_author and $wp_query->is_category. The problem is that WP_Query, based on the given query vars, will generate the page using DB request:

SELECT SQL_CALC_FOUND_ROWS  wpdb_posts.ID FROM wpdb_posts  INNER JOIN wpdb_term_relationships ON (wpdb_posts.ID = wpdb_term_relationships.object_id) WHERE 1=1  AND ( wpdb_term_relationships.term_taxonomy_id IN (1) ) AND (wpdb_posts.post_author = 1) AND wpdb_posts.post_type = 'post' AND (wpdb_posts.post_status = 'publish' OR wpdb_posts.post_status = 'private') GROUP BY wpdb_posts.ID ORDER BY wpdb_posts.post_date DESC LIMIT 0, 5

On default Twenty Eleven, it returns a Category page with error:

Notice: Undefined property: stdClass::$user_nicename in D:\Webserver\wordpress\wp-includes\post-template.php on line 456

Notice: Undefined property: stdClass::$ID in D:\Webserver\wordpress\wp-includes\post-template.php on line 456

Notice: Undefined property: stdClass::$ID in D:\Webserver\wordpress\wp-includes\post-template.php on line 457

Fixing the post-template.php WILL NOT be the solid solution. IMHO, I suggest to tweak the WP_Query class a bit to make it decide which query var will be use.

Temporary solution that works for me to handle this situation is redirecting visitors when such condition occurred to a custom search results page.

It could be happened once in thousands years, but not if there are thousands like me who like to inject queries in some random URL. :)

Change History (1)

comment:1 SergeyBiryukov2 years ago

  • Keywords needs-testing needs-patch removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Severity changed from critical to normal
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.