[wp-trac] [WordPress Trac] #22271: get_post_class() does not always apply filter to output

WordPress Trac noreply at wordpress.org
Sun Nov 4 14:40:48 UTC 2012


#22271: get_post_class() does not always apply filter to output
-----------------------------+------------------------------
 Reporter:  F J Kaiser       |       Owner:
     Type:  defect (bug)     |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Template         |     Version:  3.4
 Severity:  normal           |  Resolution:
 Keywords:  has-patch close  |
-----------------------------+------------------------------

Comment (by Rarst):

 There is a conflict of two expectations here:

 1. Function that applies filter to its return will do so in all cases.

 This is ''generic'' expectation. I expect (possibly mistakenly, but it
 ''makes sense'' to me) WP to behave like this and would be (am) surprised
 when it's not the case. Note that "why would it apply filter in some
 specific case" defeats this expectation in generic form. It is "filter
 return", not "filter return sometimes".

 2. `post_class` filter will always pass valid post ID.

 This is ''specific'' expectation. It is formed by how code works
 ''historically'' and in my perception was not intentionally engineered. It
 is not a ''goal'' of this filter to only pass valid ID. ID is just meta
 information there without explicit guarantee of validity. There are a lot
 of functions that verify if they have been passed valid input (including
 `get_post_class()` itself) instead of arguing that they should always
 receive only valid input.

 So what this ticket boils down - which of the two expectations is more
 important to uphold.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/22271#comment:20>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list