[wp-trac] [WordPress Trac] #32077: get_pages re-factor to reduce line-count, DRY up code & give more specific functions for some of it's main processes

WordPress Trac noreply at wordpress.org
Thu Apr 23 17:44:28 UTC 2015


#32077: get_pages re-factor to reduce line-count, DRY up code & give more specific
functions for some of it's main processes
------------------------------------------+--------------------------------
 Reporter:  LewisCowles                   |       Owner:
     Type:  enhancement                   |      Status:  new
 Priority:  normal                        |   Milestone:  Awaiting Review
Component:  Posts, Post Types             |     Version:  1.5
 Severity:  normal                        |  Resolution:
 Keywords:  needs-patch needs-unit-tests  |     Focuses:  docs, performance
------------------------------------------+--------------------------------

Comment (by boonebgorges):

 > Do you mean querying post_types as a generic class?

 I assume @helen meant: `get_pages()` should use `WP_Query`.

 We generally avoid refactoring for refactoring's sake. Making
 `get_pages()` more readable, more DRY, etc are good things, but if these
 are the only gains, then it may not be worth the cost of potential
 regressions.  See https://make.wordpress.org/core/2011/03/23/code-
 refactoring/ for more about this philosophy.

 That said, converting `get_pages()` to use `WP_Query` - see
 https://core.trac.wordpress.org/ticket/12821#comment:47 - is probably
 worthwhile. The more we can centralize the generation of query SQL, post
 caching, and other stuff like that, the better off we'll be in the long
 run. If you'd like to work on this project, I'd recommend closing this
 ticket in favor of #12821 and using
 https://core.trac.wordpress.org/attachment/ticket/12821/12821-wp-
 query.diff as a starting point - copious unit tests for the existing
 `get_pages()` would be the natural starting point.

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


More information about the wp-trac mailing list