Skip to content

Commit

Permalink
Attachments: dedupe earlier to prevent incorrect max_media (Automatti…
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwiebe committed Nov 17, 2023
1 parent 21206ec commit c35ddf1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion includes/transformer/class-post.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ protected function get_block_attachments( $max_media ) {
$blocks = \parse_blocks( $this->wp_post->post_content );
$media_ids = self::get_media_ids_from_blocks( $blocks, $media_ids, $max_media );
}
$media_ids = \array_unique( $media_ids );

return \array_filter( \array_map( array( self::class, 'wp_attachment_to_activity_attachment' ), $media_ids ) );
}
Expand Down Expand Up @@ -279,6 +278,9 @@ protected static function get_media_ids_from_blocks( $blocks, $media_ids, $max_m
break;
}

// depupe
$media_ids = \array_unique( $media_ids );

// stop doing unneeded work
if ( count( $media_ids ) >= $max_media ) {
break;
Expand Down

0 comments on commit c35ddf1

Please sign in to comment.