Follow-up to #2831936: Add "File" MediaSource plugin

Problem/Motivation

From #2831936-158: Add "File" MediaSource plugin :

At the moment, media is marked experimental, obviously we're trying to make it stable before 8.4.0 is released (otherwise we'll probably have to remove it from the 8.4.x branch and immediately put it back into 8.5.x to try again).

To do that, we need to keep media self-contained, putting the config into standard (even though it's optional) undermines that self-containment.

Proposed resolution

From #2831936-158: Add "File" MediaSource plugin :

we should open a follow-up to add the configuration, or add it to media for now with a follow-up to move it to standard when media's ready to go stable. That's one extra issue/patch, but worth it to keep things in one place for me.

Remaining tasks

Comments

vijaycs85 created an issue. See original summary.

vijaycs85’s picture

Issue summary: View changes
berdir’s picture

Follow-ups shouldn't use the original issue as parent. It can't be a sub-task of closed issue. Not sure if there's a diferent parent we should use, maybe the ideas issue?

Actually, I would recommend to keep it/move it now to the install profile.

I think having the configuration in the install profile is better because having it in the module will interfere with existing install profiles like thunder, lightning and so on as they already have their own media types they provide, it's not easily possible for an install profile to prevent configuration from a module to be installed (all you can do is delete it in hook_install()). Pretty sure that they will want to keep their own media bundles/types as existing data would otherwise be very hard to convert.

phenaproxima’s picture

Title: Move file configuration to profile once media is stable » Move File media type into Standard once Media is stable
phenaproxima’s picture

As I explained in #2831936-169: Add "File" MediaSource plugin, but would like to reiterate here:

As of that patch, several Media tests are deleting the File media type in their setUp() method. This is because the default configuration is, at the time of this writing, packaged with Media module rather than an install profile. Once we move the configuration into Standard, we will be able to delete those lines in the tests' setUp() method, since the tests will then be running without any default configuration (as they were originally written to do).

vijaycs85’s picture

Basically we need to revert the diff file from #2831936-169: Add "File" MediaSource plugin

wim leers’s picture

Status: Active » Postponed

This is blocked on Media becoming stable.

seanb’s picture

Title: Move File media type into Standard once Media is stable » Move File/Image media type into Standard once Media is stable

We need to move the image config back as well. #2831937-70: Add "Image" MediaSource plugin

wim leers’s picture

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

chr.fritsch’s picture

Media is stable now, so we are able to un-postpone this, right?

Last week i tried to run Thunder with core media and it turned out, that we are having some problems when the config lives in the media module and not in the profile. We are providing our own media type image with some third_party_settings and using a different field name for the source field.

So things would be much easier, if we could move the config into the profile.

chr.fritsch’s picture

Status: Postponed » Active

As discussed with @xjm during media meeting, we will unpostpone this to discuss if we could do this. As @berdir mentioned in #3 having the config in the module, brings some problems for install profiles.

I would propose to move the entity displays, field config and media types into config/optional of the standard profile. In that way it will only be installed if someone enables media module. Same as current behavior. But it would make it much easier for distributions to ship their own config.

chr.fritsch’s picture

Status: Active » Needs review
StatusFileSize
new3.6 KB

Here is a patch to my suggestions from #12. I also moved the field storage, because they are coupled so tight to the media types

Status: Needs review » Needs work

The last submitted patch, 13: move_file_image_media-2883813-13.patch, failed testing. View results

berdir’s picture

Priority: Normal » Major

We'll also need to revert the test changes from the other issue that originally moved it I guess.

But I'm very +1 to this, this would make it hard for existing install profiles to migrate from media to media_entity (and keep the media types the same for new and existing types).

We can not prevent config from being installed, best we could do is deleting them again in hook_install().

It also needs to happen before 8.4.0, afterwards it might be a BC break?

chr.fritsch’s picture

Status: Needs work » Needs review
StatusFileSize
new12.04 KB
new6.82 KB

All the tests should be fixed

berdir’s picture

Status: Needs review » Needs work
+++ b/core/modules/media/tests/src/FunctionalJavascript/MediaViewsWizardTest.php
@@ -14,6 +14,21 @@
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = [
+    'system',
+    'node',
+    'field_ui',
+    'views_ui',
+    'media',
+    'media_test_source',
+    'media_test_type',
+  ];

it's not necessary to duplicate the module list from the parent, just add the additional ones. Not sure I understand why media_test_type is required now for this test? Is it because we need a media type to exist? Why in some cases we create one through the API and in this case we rely on the test module?

chr.fritsch’s picture

Status: Needs work » Needs review
StatusFileSize
new12 KB
new907 bytes

Ok, i changed it to use the API for a media type creation. We are relying just once on the media_test_type now. When we are testing the creation from default configuration.

berdir’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, looks good to me as I mentioned, this would be quite important for install profiles to get in before 8.4.0.

chr.fritsch’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/media/tests/src/Functional/MediaFunctionalTestCreateMediaTypeTrait.php
@@ -61,6 +62,11 @@ protected function createMediaType(array $values = [], $source = 'test') {
+      ->setComponent($source_field->getName(), ['type' => 'file_generic'])

This doesn't work for an image source. The type must be fetched from the source field before somehow

chr.fritsch’s picture

Status: Needs work » Needs review
StatusFileSize
new11.97 KB
new645 bytes

I just removed the type, so the WidgetPluginManager will handle it.

berdir’s picture

What exactly was the problem and why didn't tests fail?

berdir’s picture

Status: Needs review » Needs work

The last submitted patch, 21: move_file_image_media-2883813-21.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

chr.fritsch’s picture

Status: Needs work » Needs review
StatusFileSize
new13.73 KB
new3.01 KB

Regarding #22: createMediaType() can be used to create media types from different sources. Having 'type' => 'file_generic' would only work, if the source field is a file field.

I changed the field name from field_media_file_1 to field_media_file in the new tests of #2835767: Media + REST: comprehensive test coverage for Media + MediaType entity types

wim leers’s picture

Related issues: +#2835767: Media + REST: comprehensive test coverage for Media + MediaType entity types
StatusFileSize
new14.12 KB
new2.24 KB

Yay, this patch is making the test coverage added by #2835767: Media + REST: comprehensive test coverage for Media + MediaType entity types more elegant — it addresses @effulgentsia's feedback at #2835767-70: Media + REST: comprehensive test coverage for Media + MediaType entity types and #2835767-73: Media + REST: comprehensive test coverage for Media + MediaType entity types.

Which means that for this patch to pass tests, it needs to make tiny modifications to the test coverage introduced by #2835767.

wim leers’s picture

StatusFileSize
new2.86 KB
new14.95 KB

#25 and #26 are cross-posts. The solution in #25 is incomplete.

In this patch, I'm also importing the other changes #25 made.

wim leers’s picture

The last submitted patch, , failed testing. View results

catch’s picture

I think this would still be OK to commit during rc, but otherwise would need to wait until 8.5.x.

The only way I can see this being an actual bc break is if someone's relying on the default configuration existing, then it doesn't, but we don't offer any guarantee that default config exists. Is there any other implication I missed?

wim leers’s picture

I think you're right, @catch.

Also, from #drupal-media on IRC:

16:35:18 <chrfritsch> Ok, here are my updates: I worked on https://www.drupal.org/node/2883813 the last days, because it's essential for distributions to use media. So i think it's fine now and could be pushed back to RTBC now
16:35:19 <drupalbot> https://www.drupal.org/node/2883813 => Move File/Image media type into Standard once Media is stable #2883813: Move File/Image media type into Standard once Media is stable => 29 comments, 5 IRC mentions
16:36:26 <chrfritsch> So would be really nice to get that landed in 8.4
…
GaborHojtsy> chrfritsch: hm, not sure https://www.drupal.org/node/2883813 is feasible for 8.4, the RC is about to be released after all
16:43:47 <drupalbot> https://www.drupal.org/node/2883813 => Move File/Image media type into Standard once Media is stable #2883813: Move File/Image media type into Standard once Media is stable => 29 comments, 6 IRC mentions
16:44:04 — GaborHojtsy not a release manager though :D
16:47:29 <chrfritsch> GaborHojtsy: Berdir thinks this could be a BC break, in that case it should be fixed before 8.4
…

16:48:41 <chrfritsch> xjm: What's your thoughts on that?
16:48:56 <xjm> chrfritsch: Did you link the correct issue? 8.4.x is totally set now and in RC
16:49:18 <xjm> chrfritsch: Looking more closely
16:49:57 <xjm> Hmm
16:52:21 <xjm> chrfritsch: So this just adds optional config to Standard, right, and doesn't actually enable the module in Standard?
16:52:32 <chrfritsch> xjm: Correct
16:53:05 <chrfritsch> xjm: It just moves the config from media module in standard config/optional
16:59:46 <xjm> chrfritsch: catch is asking how it's actually a BC break
17:00:03 <xjm> chrfritsch: He commented on the issue
17:00:19 <xjm> Per our release policy nothing more should be going into 8.4.x for like a month now
17:00:29 <xjm> but we can discuss more on the issue I guess
17:01:33 <chrfritsch> xjm: Ok, thank you
phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

Slam-dunk.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Yay, I am so happy to see this go in. Very excited for where this leads media in 8.5 :)

  • Gábor Hojtsy committed 3e2d434 on 8.5.x
    Issue #2883813 by chr.fritsch, Wim Leers, Berdir, phenaproxima, catch:...

Status: Fixed » Closed (fixed)

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