Problem/Motivation

Due to the nature of media entities (which may depend on additional plugins that define new entity types), some confusion may happen during the transition period while moving media_entity to core.

An existing site that uses the media_entity approach will have an arbitrary set of contrib media_entity_* installed. This site won't be able to upgrade to the new API in core until all of those plugins have 2.x branches that are compatible with media in core. Because of that we should prevent the core media module from being enabled if the 1.x branch of media_entity is.

Proposed resolution

Prevent installation of the media module if a 1.x branch of media_entity is detected.

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

marcoscano created an issue. See original summary.

marcoscano’s picture

Assigned: marcoscano » Unassigned
Status: Active » Needs review
FileSize
1.06 KB
seanB’s picture

This makes sense, I think we should have a test for this as well. Leaving 'Needs review' to get more opinions.

xjm’s picture

Thanks @marcoscano. I talked about this with @larowlan, @catch, and @cilefen, and we all agreed this is a good idea in principle. Core doesn't normally "know" about contrib modules, but in this case this is a small and harmless change that will save a lot of pain for media users.

I'd suggest adding this before 8.4.x, even when the module is not shown in the UI, since it will also help with the problem of sites that have some modules ported to the core API but not others. If they update one module and it tries to enable Media for them, they will get this error.

Based on that, I suggest a few things:

  1. We should link the media_entity project page in the message.
  2. We should update the media_entity project page to describe the status of the module for 8.4.x and link the relevant core issues.
  3. We should link (and create if needed) a handbook page that explains the contrib-to-core transition in more detail. The handbook page should probably link #2860796: Plan for contributed modules with Media Entity API in core so that people can also track the current status without us having to update it all the time.
xjm’s picture

www.drupal.org/docs/8/core/modules/media is basically empty, so there's some work to be done there. :P I'll add that to the roadmap for "before the module is shown in the UI".

marcoscano’s picture

This is a revised version of the message, linking to media_entity contrib.

Message to prevent installation of media with media_entity 1.x

I'll start a draft of the text we can use for the contrib project page as well.

marcoscano’s picture

Issue tags: +Media Initiative

I don't have write permissions to the project page, but the maintainers can use this as an initial draft, if appropriate.

Media entity provides a 'base' entity for media. This is a very basic entity which can reference to all kinds of media-objects (local files, YouTube videos, Tweets, Instagram photos, ...). Media entity provides a relation between Drupal and the media resource. You can reference to/use this entity within any other Drupal entity.

This module attempts to provide the base storage component for the Drupal 8 media ecosystem.

<h2>Media Entity will be in core</h2>

This module is being moved to Drupal 8 core! You can follow the full roadmap and related issues <a href="https://www.drupal.org/node/2825215#followup-roadmap">here</a>.

<h3>Compatibility restrictions</h3>

After 8.4.x, there is a <strong>Media</strong> module in Drupal core, which includes the base API from <strong>Media Entity</strong>, as well as most of the functionality provided by <a href="https://drupal.org/project/media_entity_image">Media Entity Image</a> and <a href="https://drupal.org/project/media_entity_document">Media Entity Document</a>.

<strong>If your site currently uses <em>Media Entity</em>, in order move to the <em>Media</em> in core solution, you need to upgrade to <em>Media Entity 8.x-2.x</em> first, and then follow the upgrade path. More information on this upgrade path can be found <a href="https://www.drupal.org/node/2880334">here</a>.</strong>

Note that in order to start using the Media module in core, <strong>all provider modules defining media types (bundles) need to be upgraded as well</strong>. <a href="https://www.drupal.org/node/2860796">This issue</a> keeps track of the upgrade status of the most common contributed modules.

If you need to upgrade Drupal core to 8.4.x but you can't yet upgrade <strong>Media Entity 8.x-2.x</strong> due to some contrib modules not having 2.x branches, you still can use <strong>Media Entity 8.x-1.x</strong> with Drupal 8.4.x, as long as the core Media module is not enabled. If you can, consider helping with the <a href="https://www.drupal.org/node/2860796">upgrade of contrib modules</a>, once <strong>Media Entity 8.x-1.x</strong> will loose support at some point in the future.

(...)

(and sorry for language imprecisions... having a non-native speaker writing documentation in English is never the best idea :)

marcoscano’s picture

Re: #5:

www.drupal.org/docs/8/core/modules/media is basically empty, so there's some work to be done there. :P I'll add that to the roadmap for "before the module is shown in the UI".

We've been traditionally using the GitBook handbook as documentation for the contrib ecosystem. I remember helping out with some Media Entity pages a while back actually: https://drupal-media.gitbooks.io/drupal8-guide/content/modules/media_ent...

We could probably migrate part of this info to the Drupal documentation page, adjusting what makes sense for the changes that happened for Media in core. As an initial step, though, I believe we could have in the Drupal documentation page the detailed instructions from #2880334: Add update path of media_entity config changes from 1.x to core media module at least.

Wim Leers’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Core doesn't normally "know" about contrib modules, but in this case this is a small and harmless change that will save a lot of pain for media users.

I know that this caused a lot of frustration/WTFs for the sites using BigPipe, when BigPipe was added to core. So +1 to taking the pragmatic approach here :)

I think the key thing that's missing here, is test coverage. Basically, a test that proves that when media_entity 8.x-1.x is installed, this error is shown, and when 8.x-2.x is installed, it is not shown.

Berdir’s picture

And how do we test that exactly? We can't mock system_get_info() nor unit-test a requirements hook, and while we could have a media_entity test module, that would only be one version and might be weird if media_entity is also on the system.

Wim Leers’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests

Ugh :(

By looking at the code, I guess we can test it by prepopulating a particular cache item:

function system_get_info($type, $name = NULL) {
  if ($type == 'module') {
    $info = &drupal_static(__FUNCTION__);
    if (!isset($info)) {
      if ($cache = \Drupal::cache()->get('system.module.info')) {

But that's obviously pretty brittle.

I defer the decision whether this needs test coverage or not to the committers then.

Berdir’s picture

That's an interesting idea, we could possibly mess with the static cache there, true.

Agreed, lets defer this decision to committers then, should we assign/tag the issue or mark it as RTBC? Not sure if there's something else left to do here?

We have #2208429: Extension System, Part III: ExtensionList, ModuleExtensionList and ProfileExtensionList which would break the static cache trickery but might make it possible to mock the underlying service in a kernel test (unit is not an option because this is a function as I mentioned). So if we do something with the static cache here, we'll have to update it in that issue.

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.

slashrsm’s picture

Version: 8.5.x-dev » 8.4.x-dev
Status: Needs review » Reviewed & tested by the community

Updated Media entity project page with #7 + few minor fixes. It would be great if any native speakers could review and correct the text. Huge thanks to @marcoscano for this!

I will RTBC this as it looks OK in general. I agree that we wait on committer feedback re tests.

Also moving it back to 8.4. I am aware that this could be tricky, but it should not interfere with any other system and that the benefit of this would likely be significantly diminished if we would need to wait until 8.5. Also citing @Berdir:

this is almost a bugfix imho

:)

  • xjm committed b05897e on 8.5.x
    Issue #2896427 by marcoscano, Wim Leers, xjm, Berdir, slashrsm: Prevent...

  • xjm committed 15ea1a7 on 8.4.x
    Issue #2896427 by marcoscano, Wim Leers, xjm, Berdir, slashrsm: Prevent...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Looks like xjm didn't get to marking this fixed, so I will :)

I'm also OK with no test coverage here, it's well outside the critical path and a messy system to test.

xjm’s picture

Issue tags: +8.4.0 release notes

Before: Flame! Death! Destruction!
After:

Module media doesn't meet the requirements to be enabled.            [error]
The Media module is not compatible with contrib Media Entity 1.x     [error]
branch. Please check the 2.x branch of that module for an upgrade
path.

Committed and pushed to 8.5.x. I also backported this to 8.4.x since it will prevent painful upgrades around 8.4.0. Thanks!

This is something media users need to be aware of so we should add it to the release notes. No test needed.

Status: Fixed » Closed (fixed)

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