After upgrading to 8.5.0 core media from media_entity 1.x, the recommendation is to remove the uninstalled media_entity 2.x module from the codebase.

Doing so produces a warning for me, it seems the system is still looking for the media_entity.install file:

User warning: The following module is missing from the file system: media_entity in drupal_get_filename() (line 268 of core/includes/bootstrap.inc).
drupal_get_filename('module', 'media_entity') (Line: 291)
drupal_get_path('module', 'media_entity') (Line: 134)
module_load_include('install', 'media_entity') (Line: 93)
module_load_install('media_entity') (Line: 82)
drupal_load_updates() (Line: 109)
Drupal\system\SystemManager->listRequirements() (Line: 96)
Drupal\system\SystemManager->checkRequirements() (Line: 102)
Drupal\system\Controller\SystemController->overview('system.admin_config')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 657)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Comments

John Pitcairn created an issue. See original summary.

marcoscano’s picture

Issue tags: +Media Initiative

Did you experience any problems or error messages while running the DB updates?
It seems that it still thinks that the module is enabled, but the updb code should have uninstalled it. I assume an additional cache clear doesn't solve the warning message, right?

johnpitcairn’s picture

Hmm ... I am now about a hundred cache clears and a few cron runs further on and it does seem to have disappeared in the UI.

I still get it if I run drush updatedb or visit /update.php

Mytko Enko’s picture

johnpitcairn’s picture

@Mytko Enko: Yes removing media_entity from the system schema via direct sql query does work, but it's a something of a last resort, and leaves me wondering if there are other problems it may be masking. I'd much prefer putting the module back into the codebase and uninstalling it manually, but of course that isn't really possible or advisable post-upgrade.

karlshea’s picture

I'm also getting the same error. No warnings or anything during the upgrade process.

spokje’s picture

Same error here, also no warnings/errors during upgrade process.

To make this a bit more useful post, and saving anyone the extra click for #4, this does the trick:

drush sql-query "DELETE FROM key_value WHERE collection='system.schema' AND name='media_entity'"

But I also agree with #5. It's a last resort and not something you want every user that is going to migrate to Core Media having to do.

tstoeckler’s picture

Priority: Normal » Major

Hit this as well today. This is because Media Entity is uninstalled from within an update function from the module itself. What happens is that even though during the installation the schema version is correctly removed, after the update has finished update_do_one() calls drupal_set_installed_schema_version($module, $number) so that there will still be a lingering schema version afterwards.

Afterwards any call to drupal_load_updates() will find that schema version and will call module_load_install('media_entity') which will trigger the error above.

Not sure yet what to do about this, but it's certainly a major issue.

I guess we could maybe run something in core to clean this up?

tstoeckler’s picture

This is what fixed it for me in a custom module.

/**
 * Remove 'media_entity' from the system schema list.
 */
function MYMODULE_update_8002() {
  $schema_store = \Drupal::keyValue('system.schema');
  $schema_store->delete('media_entity');
}
hchonov’s picture

Should we add this to the core media module to fix this for installations, which have been updated already?

tstoeckler’s picture

Yes, I think that would make sense. It certainly must be run by code that is not inside media_entity itself, so I think the core media module would be a logical place, especially since something along the lines of #9 should suffice and that's not really a lot of code to maintain.

I'd be interested to hear what the Media maintainers say about this, though.

hchonov’s picture

Project: Media entity » Drupal core
Version: 8.x-2.x-dev » 8.6.x-dev
Component: Code » media system

Tentatively moving the issue to the Core media system. Feel free to revert, but I think that makes the most sense.

seanb’s picture

I agree this is an annoying issue, but I don't think we should solve this in a core update hook. Maybe a new branch of media_entity with a uninstall hook that fixes this? You can install and directly uninstall media_entity 3.x to fix it if you don't want to add your own update hook?

hchonov’s picture

I am not sure that it is nice to ask people to install a specific version of the media_entity module as they moved from it to the core one. We cannot reach to all the people, but with a core media update we'll fix all sites silently without having to inform anyone about anything. The media core module is aware of the media_entity module - see media_requirements() in media.install, therefore I don't think there is a problem with adding a simple update to the media module.

Version: 8.6.x-dev » 8.7.x-dev

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

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

frederickjh’s picture

@tstoeckler Thanks for the code. That solved it for me.

For those GUI users there should be some sort of resolution to this issue that does not involve a custom module or the command line.

tstoeckler’s picture

chr.fritsch’s picture

I think we can close this issue since #3063719: Remove media_entity from the update schema list was merged

tstoeckler’s picture

I personally think it would be nice to clean this up for people that have already done the upgrade, since Media in Core has been stable for a while. We could add an update hook to the Media module. Going on #9, we could do something like this:

/**
 * Remove obsolete 'media_entity' reference from the schema store.
 */
function media_update_****() {
  $schema_store = \Drupal::keyValue('system.schema');
  $schema_version = $schema_store->get('media_entity', FALSE);
  // Early versions of the Media Entity upgrade path did not remove the schema
  // version properly after uninstalling itself. Remove the obsolete reference in
  // this case.
  if ($schema_version && ($schema_version == 8201) && !\Drupal::moduleHandler()->moduleExists('media_entity')) {
    $schema_store->delete('media_entity');
  }
}
chr.fritsch’s picture

Title: Media upgrade: Removing uninstalled media_entity module produces warning message » Cleanup update schema for already migrated sites
Project: Drupal core » Media entity
Version: 8.8.x-dev » 8.x-2.x-dev
Component: media system » Code

Sounds like a plan. I am moving this back to the media_entity issue queue

berdir’s picture

this can't be solved in media_entity, because that is already uninstalled, it can only be done from a module that's still installed and media in core would be an obvious choice.

chr.fritsch’s picture

Project: Media entity » Drupal core
Version: 8.x-2.x-dev » 8.8.x-dev
Component: Code » media system

Ahh, stupid me. 🙈

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.