[wp-trac] [WordPress Trac] #24684: posts_clauses Query filter should have array as argument

WordPress Trac noreply at wordpress.org
Mon Aug 12 16:26:18 UTC 2013


#24684: posts_clauses Query filter should have array as argument
-------------------------+------------------------------
 Reporter:  F J Kaiser   |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Query        |     Version:  3.5.2
 Severity:  normal       |  Resolution:
 Keywords:  needs-patch  |
-------------------------+------------------------------

Comment (by TJNowell):

 Replying to [comment:5 wonderboymusic]:
 > > no major rewrite
 > > Actually the patch would ''just'' replace all the string concatenating
 with array pushing
 >
 > What isn't major about that?

 I'd have to agree with Kaiser, but I would say get_posts is in desperate
 need of a major refactor. Or at least breaking up into separate methods

 Infact, I know with certainty it is required, most computer scientists
 will advise that a method should have an NPath complexity of less than
 200,  and get_posts has an NPath complexity of:

 '''1,435,733,941,397,422,709,124,940,625,188,500,371,668,992,000,000'''

 or 1x10^49^, which is 25 orders of magnitude greater than the number of
 stars in the visible universe

 When a method needs more unit tests to verify it works than there are
 stars in the universe and grains of sand on all the beaches in the solar
 system, I can surmise that swapping out some string concatenation for some
 array insertions is trivial in comparison.

 That stupendous number could easily be brought down very quickly, and the
 changes necessary will go a long way towards making that method more
 maintainable. Perhaps Kaiser has a patch ready I'm unaware of, but
 anything that modifies get_posts is likely to be a good thing, after all,
 that number can't get much higher.

 ''For those watching who are unaware http://www.codingswag.com/2013/05
 /cyclomatic-and-npath-complexity-explained/ ''

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


More information about the wp-trac mailing list