Posts are duplicating on wp_post_update

Ah, I found the answer myself. I’ve added global $post before the loop and now all seems to works fine. I don’t know if this is a good practice, so if you have another ideas share them 🙂

Here is the revised code:

add_action('save_post', 'bulk_refresh');
function bulk_refresh($post_id) {
if($post_id != 123)//123 is the 'certain page' id
    return;
global $post;
$posts_to_update = new WP_Query(array('post_type' => 'MY_CUSTOM_TYPE', 'posts_per_page' => -1));
while($posts_to_update ->have_posts()) : $posts_to_update ->the_post();
    $args = array( 'ID' => $post->ID );
    wp_update_post( $args );
endwhile;
// Reset Post Data
wp_reset_postdata();
}