[wp-trac] [WordPress Trac] #20297: WP_Query implements IteratorAggregate

WordPress Trac wp-trac at lists.automattic.com
Mon Mar 26 09:50:39 UTC 2012


#20297: WP_Query implements IteratorAggregate
-----------------------------+------------------------------
 Reporter:  hakre            |       Owner:
     Type:  feature request  |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  General          |     Version:
 Severity:  normal           |  Resolution:
 Keywords:  has-patch close  |
-----------------------------+------------------------------

Comment (by hakre):

 Yes, {{{IteratorAggregate}}} is a light approach here. The patch is
 available so it's something to play with. I also thought about the
 shortcomings because of {{{setup_postdata}}}, a much nicer thing would be
 to have {{{WP_Query}}} and an {{{Iterator}}} for it which can replace the
 {{{ArrayIterator}}} - an external iterator still aggregated. However I
 wanted to keep this first suggestion light, I think {{{WP_Query}}} is a
 potential class that could benefit from PHP's traversable features and
 that's the main point.

 Sure this little patch can't do all the magic - would be cool, but as
 noted, it does not show the whole picture.

 If there's something like {{{WP_Post}}} I think there would be some list-
 class like {{{WP_Posts}}} which is traversable anyway.

 Maybe using an iterator internally in {{{WP_Query}}} will make future
 changes more feasible.

 About compilter flags: The SPL is compiled in with nearly every standard
 distribution. As with any other compile feature, things can be disabled
 which are commonly not, but we don't care much about all those other
 compile flags as well. Just to put this into the right light, the SPL
 ain't some esoteric feature, it's generally available with PHP 5.2 and
 above so it's really safe to use.

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


More information about the wp-trac mailing list