Bug Found (Network_Query Class)

Hi folks,

I was writing a plugin which used the Network_Query class and found that if get_posts() is called, the $posts array will contain the posts from the last time it was called in addition to the results from the present call.

Since get_posts is called when Network_Query is instantiated, any subsequent calls will always cause the posts array to be "double populated".

You can quickly reproduce this by doing something to the effect of:

$wp_query = new Network_Query( $query_variables );
$posts = $wp_query->get_posts();

This is caused by the area around line 2672 in networkquery.php. The function always appends the retrieved posts to the $posts array and never clears it (if you look at the commented out code from WP_Query on 2675, you will see $posts gets overwritten in the default implementation).

I've worked around this behavior by pulling from $posts directly (to avoid editing Post Indexer itself); since get_posts is public and Network_Query is designed to function exactly like WP_Query, it might be worth implementing a fix.

Thanks!