Attachments: dedupe earlier to prevent incorrect max_media

This commit is contained in:
Matt Wiebe 2023-11-17 12:19:06 +01:00
parent efd98acd0b
commit d7d084b875

View file

@ -185,7 +185,6 @@ class Post {
$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 ) );
}
@ -279,6 +278,9 @@ class Post {
break;
}
// depupe
$media_ids = \array_unique( $media_ids );
// stop doing unneeded work
if ( count( $media_ids ) >= $max_media ) {
break;