Skip to:
Content

bbPress.org

Opened 8 years ago

Closed 8 years ago

#1947 closed defect (fixed)

un-wanted : wp_query is_home set to true when topic and replies are listed

Reported by: michelwppi Owned by:
Milestone: 2.2 Priority: normal
Severity: normal Version: 2.1.2
Component: General Keywords:
Cc:

Description

Occuring side effects in a future version of xili-language to attach language to forum, after long research I found that;

When this query is launched to display one topic AND replies

SELECT SQL_CALC_FOUND_ROWS  wp_3_posts.* FROM wp_3_posts  FORCE INDEX (PRIMARY, post_parent) WHERE 1=1 AND (wp_3_posts.ID = 26 OR wp_3_posts.post_parent = 26)  AND wp_3_posts.post_type IN ('topic', 'reply') AND (wp_3_posts.post_status = 'publish' OR wp_3_posts.post_status = 'closed')  ORDER BY wp_3_posts.post_date ASC LIMIT 0, 15

by

function bbp_has_replies( $args = '' ) {

is_home is set to true here in query.php

if ( !( $this->is_singular || $this->is_archive || $this->is_search || $this->is_feed || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_comments_popup || $this->is_robots ) )
			$this->is_home = true;
error_log ( 'here ---------- ' . serialize ( $this->is_home ) );

The other queries (forum,...) don't set is_home to true

It is probabely because the query search topic AND reply together and than the lines below don't work :

if ( !empty( $qv['post_type'] ) && ! is_array( $qv['post_type'] ) ) {
				$post_type_obj = get_post_type_object( $qv['post_type'] );
				if ( ! empty( $post_type_obj->has_archive ) )
					$this->is_post_type_archive = true;
			}

Thanks for your suggestion

Change History (3)

#1 @michelwppi
8 years ago

A temporary fixe avoiding modifying core of the xili-language plugin added in another small plugin adding multilingual features to bbpress:

if ( ! is_admin() ) add_action( 'parse_query', 'xiliml_bbpress_parse_query' );

function xiliml_bbpress_parse_query ( $wp_query ) {
if ( isset ( $wp_query->query_vars['post_type' ] ) ) {
	if ( is_array ( $wp_query->query_vars['post_type' ] ) ) {
		if ( $wp_query->query_vars['post_type' ] = array( bbp_get_topic_post_type(), bbp_get_reply_post_type() ) ) {
			//error_log (' QUERY '.serialize ( $wp_query->query_vars['post_type' ] ));
			$wp_query->is_home = false ;
		}
	}
}
}
Last edited 8 years ago by michelwppi (previous) (diff)

#2 @johnjamesjacoby
8 years ago

  • Milestone changed from Awaiting Review to 2.2

Confirmed. Fix incoming.

#3 @johnjamesjacoby
8 years ago

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

(In [4216]) Single topics:

  • Force is_home to false in bbp_has_replies()
  • Maybe set is_single to true if viewing a single topic.
  • Fixes bug where WP_Query::parse_query() incorrectly assumes is_home() when multiple post_types are queried.
  • Fixes #1947.
Note: See TracTickets for help on using tickets.