Attachments: dedupe earlier to prevent incorrect max_media (#565)

This commit is contained in:
Matt Wiebe 2023-11-17 18:44:59 +01:00 committed by GitHub
parent 21206ecda0
commit c35ddf1935
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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;