Skip to:
Content

bbPress.org

Opened 22 months ago

Closed 22 months ago

Last modified 22 months ago

#3334 closed defect (bug) (fixed)

is_bbpress() should check if WordPress is initialized first

Reported by: r-a-y Owned by: johnjamesjacoby
Milestone: 2.6.5 Priority: normal
Severity: normal Version: 2.0
Component: API Keywords: has-patch
Cc:

Description

A fatal error will occur when attempting to use is_bbpress() before the main query is initialized.

I ran into this when using the is_bbpress() function inside a filter that runs before and after the main query is executed.

is_bbpress() should follow other similar WordPress conditional query functions like is_archive() so a fatal error does not occur.

Attached is a patch that uses the same WP logic.

Attachments (2)

3334.01.patch (725 bytes) - added by r-a-y 22 months ago.
3334.02.patch (749 bytes) - added by r-a-y 22 months ago.

Download all attachments as: .zip

Change History (7)

@r-a-y
22 months ago

@r-a-y
22 months ago

#1 @johnjamesjacoby
22 months ago

  • Milestone changed from Awaiting Review to 2.6.5
  • Owner set to johnjamesjacoby
  • Status changed from new to assigned

#2 @johnjamesjacoby
22 months ago

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

In 7066:

Templates: avoid possible fatal error in is_bbpress().

This commit confirms that the $wp_query global has been invoked before attempting to make comparisons against it. It also uses _doing_it_wrong() to alert developers to what is going on.

Props r-a-y. Fixes #3334. For 2.7, trunk.

#3 @johnjamesjacoby
22 months ago

In 7067:

Templates: avoid possible fatal error in is_bbpress().

This commit confirms that the $wp_query global has been invoked before attempting to make comparisons against it. It also uses _doing_it_wrong() to alert developers to what is going on.

Props r-a-y. Fixes #3334. For 2.6.15, branches/2.6.

#4 @johnjamesjacoby
22 months ago

In 7068:

Templates: avoid $wp_query global touches.

This commit replaces direct $wp_query touches with calls to bbp_get_wp_query() which is designed for this purpose. Combined with the filter inside of bbp_get_global_object() this enables originally intended flexibility inside of the template stack.

See #3334. For 2.6.15, branches/2.6.

#5 @johnjamesjacoby
22 months ago

In 7069:

Templates: avoid $wp_query global touches.

This commit replaces direct $wp_query touches with calls to bbp_get_wp_query() which is designed for this purpose. Combined with the filter inside of bbp_get_global_object() this enables originally intended flexibility inside of the template stack.

See #3334. For 2.7, trunk.

Note: See TracTickets for help on using tickets.