Custom Post save causes 500 error

I found an answer.

Essentially I had an infinite loop that was quite puzzling at first. It made more sense as I saw that it never iterated beyond the first item in the post array.

I found the answer here:
https://tommcfarlin.com/update-post-in-save-post-action/

The issue is that wp_update_post hooks into save_post… so every time I would reach that, it would restart again. To fix this, I changed my code to read:

function officers_onto_board_page_save( $post_id ) {
    remove_action( 'save_post', 'officers_onto_board_page_save' );


    //DO STUFF


   add_action( 'save_post', 'officers_onto_board_page_save');
}

By removing the function and then re-adding it to save_post, it operates as expected.