Problem/Motivation

Currently the module creates a field storage and config automatically as soon as a media bundle of type video_embed_field is created. It is a problem in case of modules like media which import their own configurations for the media bundles with fields.

Proposed resolution

Let's check if the field for the video URL already exists for the media bundle and if it exists then not create a field automatically.

CommentFileSizeAuthor
#5 2743665-5.patch798 bytesroyal121
#2 2743665-2.patch778 bytesroyal121

Comments

royal121 created an issue. See original summary.

royal121’s picture

Status: Active » Needs review
StatusFileSize
new778 bytes
sam152’s picture

That makes sense. We've looked at this before and the check:

> !$media_bundle->isSyncing()

Is meant to catch the case where config is being imported, but I think it's worth being more defensive and checking the media entity config as well.

+++ b/modules/video_embed_media/video_embed_media.module
@@ -12,7 +12,7 @@ use Drupal\video_embed_media\Plugin\MediaEntity\Type\VideoEmbedField;
+  if ($media_bundle->type === 'video_embed_field' && !$media_bundle->isSyncing() && empty($media_bundle->type_configuration)) {

Lets use the getTypeConfiguration method instead.

Can we also check the specific "source_field" configuration option? If somehow media bundles are created in the future with some default configuration, this would break.

sam152’s picture

Status: Needs review » Needs work
royal121’s picture

Status: Needs work » Needs review
StatusFileSize
new798 bytes
slashrsm’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me.

sam152’s picture

Thanks for your efforts.

sam152’s picture

Status: Reviewed & tested by the community » Fixed

  • Sam152 committed 21d9cf1 on 8.x-1.x authored by royal121
    Issue #2743665 by royal121, Sam152, slashrsm: Create Video embed field...
sam152’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.