WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 5 years ago

#11878 closed defect (bug) (fixed)

Null value passed to apply_filters when get_post_class() is called without parameters.

Reported by: Utkarsh Owned by: nacin
Milestone: 3.0 Priority: low
Severity: minor Version: 2.9
Component: General Keywords: has-patch
Focuses: Cc:

Description

If post_class is called without a post_id, null value is passed to apply_filters as the post_id, instead of the ID of the current post.

Attachments (2)

11878.patch (383 bytes) - added by Utkarsh 6 years ago.
Patch
11878.2.patch (436 bytes) - added by scribu 6 years ago.
First check $post_id, then get post

Download all attachments as: .zip

Change History (6)

@Utkarsh6 years ago

Patch

comment:1 @Utkarsh6 years ago

  • Keywords has-patch added

@scribu6 years ago

First check $post_id, then get post

comment:2 @scribu6 years ago

In 11878.2.patch I've moved the is_null() check before retrieving the post.

comment:3 @nacin5 years ago

  • Owner set to nacin
  • Status changed from new to accepted

It looks like we should just change $post_id to $post->ID in the filter.

comment:4 @nacin5 years ago

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

(In [13462]) Pass post ID to post_class filter, even when calling post_class() without parameters in the loop. fixes #11878

Note: See TracTickets for help on using tickets.