Making WordPress.org

Opened 8 years ago

Closed 8 years ago

#2529 closed defect (bug) (fixed)

Support Forums: PHP notice in User Moderation plugin

Reported by: sergeybiryukov's profile SergeyBiryukov Owned by: coffee2code's profile coffee2code
Milestone: Priority: normal
Component: Support Forums Keywords: has-patch commit
Cc:

Description

  1. Log in as a flagged user that has a pending post.
  2. View that pending post.
  3. You'll get two PHP notices:
    Notice: Trying to get property of non-object in wp-includes/class-wp-query.php on line 3894
    Notice: Trying to get property of non-object in wp-includes/class-wp-query.php on line 3894
    

Plugin::posts_where() calls bbp_is_single_forum() and bbp_is_single_topic(), and they both call is_singular(). The first call happens before the wp action runs, when conditional tags are not properly set up yet. See #wp29660, specifically comment 21.

Adding did_action( 'wp' ) to the condition fixes the issue and still allows flagged users to see their pending posts, which is the purpose of this code.

Attachments (1)

meta-2529.patch (782 bytes) - added by SergeyBiryukov 8 years ago.

Download all attachments as: .zip

Change History (2)

#1 @coffee2code
8 years ago

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

In 5038:

Support Forums, User Moderation: Prevent PHP notices by checking 'wp' action has happened before making checks that call is_singular().

Props SergeyBiryukov.
Fixes #2529.

Note: See TracTickets for help on using tickets.