Skip to:
Content

bbPress.org

Opened 8 years ago

Closed 8 years ago

#3040 closed defect (bug) (duplicate)

string not converted to array on empty check

Reported by: cybr's profile Cybr Owned by:
Milestone: Priority: normal
Severity: normal Version: trunk
Component: General Keywords: reporter-feedback
Cc:

Description

Function bbp_pre_get_posts_normalize_forum_visibility() at includes/forums/functions.php has an empty check:

// Get any existing post status
$post_stati = $posts_query->get( 'post_status' );

// Default to public status
if ( empty( $post_stati ) ) {
	$post_stati[] = bbp_get_public_status_id();

// Split the status string
} elseif ( is_string( $post_stati ) ) {
	$post_stati = explode( ',', $post_stati );
}

When empty, the value could be a string. This will lead into a fatal PHP error:
Uncaught Error: [] operator not supported for strings in /.../wp-content/plugins/bbpress/includes/forums/functions.php:1800

This causes a white screen of death at /wp-admin/edit.php?post_type=forum on PHP 7.1 and 4.8-alpha-39901.

Suggestion:

// Get any existing post status
$post_stati = $posts_query->get( 'post_status' );

// Default to public status
if ( empty( $post_stati ) ) {
	// -- We know it's empty. Just reset the array.
	$post_stati = array();

	$post_stati[] = bbp_get_public_status_id();

// Split the status string
} elseif ( is_string( $post_stati ) ) {
	$post_stati = explode( ',', $post_stati );
}

Cheers!

Change History (2)

#1 @johnjamesjacoby
8 years ago

  • Keywords reporter-feedback added
  • Milestone changed from Awaiting Review to 2.6

Hey there! I believe we've fixed this in 2.6, and I'll be putting out Beta 2 today.

Would you be able to test & confirm?

#2 @johnjamesjacoby
8 years ago

  • Milestone 2.6 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Coming back to confirm this is fixed in 2.6.

Note: See TracTickets for help on using tickets.