Automattic / babble

Multilingual WordPress done right.
https://wordpress.org/plugins/babble/
245 stars 50 forks source link

Unused query #251

Closed simonwheatley closed 9 years ago

simonwheatley commented 9 years ago

This $subs_posts query is unused and should be removed.

if ( ! $subs_index )
    return $posts;
$subs_posts = get_posts( array( 'include' => array_values( $subs_index ), 'post_status' => 'publish' ) );
// @FIXME: Check the above get_posts call results are cached somewhere… I think they are
// @FIXME: Alternative approach: hook on save_post to save the current value to the translation, BUT content could get out of date – in post_content_filtered
foreach ( $posts as & $post ) {
    // @TODO why does this only override the title/excerpt/content? Why not override the post object entirely?
    // @FIXME: I'm assuming this get_post call is cached, which it seems to be
    if( isset( $subs_index[ $post->ID ] ) ) {
joehoyle commented 9 years ago

I think this may have been there originally so the below foreach loop would have populated the object cache, so all the subsequent get_post calls wouldn't need to go to the DB. However, since the introduction of $split_the_query, I'm not sure if this would really improve anything now.

I'm +1 for removing for sake of simplicity.