[wp-trac] [WordPress Trac] #12267: Introduce WP_Post class

WordPress Trac wp-trac at lists.automattic.com
Thu Jun 28 03:35:03 UTC 2012


#12267: Introduce WP_Post class
-------------------------+-----------------------------
 Reporter:  andy         |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Future Release
Component:  General      |     Version:
 Severity:  normal       |  Resolution:
 Keywords:               |
-------------------------+-----------------------------

Comment (by toppa):

 In the WP 3.5 pre-planning meeting today I said I'd take a look at this.
 I've reviewed the patches and 2 years(!) worth of comments, and I'm struck
 by the general desire to approach this with One Base Class To Rule Them
 All (comments, posts, categories, etc). The idea of being able to call a
 common set of methods for almost anything - to get authors, titles, etc -
 is definitely seductive, so I understand the appeal. But my concern is
 that the conceptual foundation of the base class is weak (i.e. comments,
 posts, categories, etc to my mind are distinctly different things that
 happen to share some attributes). I think this approach will lead to
 violations of the
 [http://en.wikipedia.org/wiki/Liskov_substitution_principle Liskov
 substitution principle]. That is, we'd ultimately end up with child
 classes that have a bunch of degenerate (unimplemented) methods and/or
 overriddes, and generally buggy/confusing behavior as the child classes
 evolve in different directions from each other.

 When WP is ready for PHP 5.4 I could see using
 [http://php.net/manual/en/language.oop5.traits.php traits] to encapsulate
 the common characteristics among posts, comments, etc. But aside from
 that, my feeling at this point is to pursue WP_Post as a class designed
 for use with posts and pages, and not try to tie it to a broadly defined
 base class (and if we later see that there is a justification for a base
 class, we can always extract it without breaking external behavior).

 I'd like to hear feedback. I have strong OO experience but I have not done
 a lot with WP core yet, so there may be aspects to this I'm missing.

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


More information about the wp-trac mailing list