[wp-trac] [WordPress Trac] #24672: Remove final from WP_Post class

WordPress Trac noreply at wordpress.org
Wed Mar 21 21:35:23 UTC 2018


#24672: Remove final from WP_Post class
-------------------------------+------------------------------
 Reporter:  carlalexander      |       Owner:
     Type:  enhancement        |      Status:  reopened
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Posts, Post Types  |     Version:  3.5
 Severity:  normal             |  Resolution:
 Keywords:  2nd-opinion        |     Focuses:
-------------------------------+------------------------------
Changes (by Andy Schmidt):

 * keywords:   => 2nd-opinion


Comment:

 With the addition of the "'''posts_pre_query'''" hook, you are now
 inviting developers to populate posts with information sourced elsewhere -
 some might even come from external databases. Consequently, it would be
 very sensible to properly EXTEND the WP_Post class and substitute the
 necessary functionality/compatibility to the individual post.

 Alternatively, if you are completely opposed to allowing WP_Post to be
 extendable, would you at least consider creating an '''Interface''', then
 have WP_Post implement your interface. In those few places in the WP code
 where "is_a" or "instanceof" is used against the class WP_Post, change it
 to "instanceof Interface". This way developers can create their own
 classes that do properly implement your interface, and your "instanceof
 Interface" will still recognize compatible object instances, without you
 having to remove "final" from your class.

 Right now, you are forcing developers to use PHP's "Componere" (or similar
 extensions) to bypass your "final" class declaration to do what's
 necessary. So your "final" declaration doesn't really accomplish anything
 as far as preventing dependencies.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/24672#comment:18>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list