[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 15:20:24 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
------------------------------------------+--------------------------------
Changes (by LewisCowles):

 * focuses:  performance => docs, performance


Comment:

 Replying to [comment:1 helen]:
 > Related / duplicate-in-spirit: #12821

 No, lol. I see what you were thinking, maybe that is an eventual goal, but
 I think it's definitely not the spirit of this.

 This is to increase readability, make documentation in the code easier to
 follow, and making it work correctly, as efficiently as possible. This has
 not added any functionality and most code is simply copied & pasted.

 As-is in trunk there are a number of oddities with the code
  * It's a massive & hard to read function with many responsibilities (in
 the patch these are sent to other helper functions)
  * One filter is applied 3 times, instead of every time the function exits
  * Some of the checks seemed a little flimsy
  * There is no separation of concerns, or ability to graph, or iterate the
 function (which this is not specifically about, but for larger systems,
 this could be a nice ability to have)

 Things I have not done are

  * add some filters for the SQL / WP_SQL, (I think deserves it's own
 issue, would help advanced plugin builders to use core code augmenting it
 with their own functionality, keeps people away from wpdb global or even
 rewriting queries / bits of queries on their own!)
  * To separate the data from the code (IMHO nice to have, maybe another
 issue, something I have raised before)
  * Maybe have an object instead of global access (again separate issue)

 None of the above are about using posts ;)

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


More information about the wp-trac mailing list