1

This is a Drupal 9.5.10. After uninstalling the Media module. The website encountered an unexpected error. The error message only shows a little information, as I know. It mentioned the "media" entity type does not exist.

The website does not have the Media Entity module. Of course, the Media module and Media types(audio, document, image, remote video, and video) should not be there because I just uninstalled it. So what does it mean? Do you know if the error message below relates to another module besides the Media? It's hard to know what needs to be fixed. How do I fix this?

If I enable the Media module by running drush en media, it will return the site, but I want to uninstall the Media module.

The website encountered an unexpected error. Please try again later.
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "media" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 139 of core/lib/Drupal/Core/Entity/EntityTypeManager.php).

Drupal\Core\Entity\EntityTypeManager->getDefinition('media') (Line: 128)
Drupal\Core\Entity\EntityDisplayBase->__construct(Array, 'entity_view_display') (Line: 178)
Drupal\Core\Entity\Entity\EntityViewDisplay->__construct(Array, 'entity_view_display') (Line: 564)
Drupal\Core\Entity\EntityDisplayBase->__wakeup()
session_start() (Line: 192)
Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start() (Line: 162)
Drupal\Core\Session\SessionManager->startNow() (Line: 110)
Drupal\Core\Session\SessionManager->start() (Line: 57)
Symfony\Component\HttpFoundation\Session\Session->start() (Line: 54)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Fatal error: Uncaught Drupal\Component\Plugin\Exception\PluginNotFoundException: The "media" entity type does not exist. in /Applications/XAMPP/xamppfiles/htdocs/localhost/web/core/lib/Drupal/Core/Entity/EntityTypeManager.php:139 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/localhost/web/core/lib/Drupal/Core/Entity/EntityFieldManager.php(219): Drupal\Core\Entity\EntityTypeManager->getDefinition('media') #1 /Applications/XAMPP/xamppfiles/htdocs/localhost/web/core/lib/Drupal/Core/Entity/EntityFieldManager.php(196): Drupal\Core\Entity\EntityFieldManager->buildBaseFieldDefinitions('media') #2 /Applications/XAMPP/xamppfiles/htdocs/localhost/web/core/lib/Drupal/Core/Entity/EntityFieldManager.php(346): Drupal\Core\Entity\EntityFieldManager->getBaseFieldDefinitions('media') #3 /Applications/XAMPP/xamppfiles/htdocs/localhost/web/core/lib/Drupal/Core/Entity/EntityDisplayBase.php(405): Drupal\Core\Entity\EntityFieldManager->getFieldDefinitions('media', 'audio') #4 /Applications/XAMPP/xamppfiles/htdocs/localhost/web/core/lib/Drupal/Core/Entity/EntityDisplayBase.php(304): Drupal\Core\Entity\EntityDisplayBase->getFieldDefinitions() #5 /Applications/XAMPP/xamppfiles/htdocs/localhost/web/core/lib/Drupal/Core/Entity/EntityDisplayBase.php(541): Drupal\Core\Entity\EntityDisplayBase->toArray() #6 [internal function]: Drupal\Core\Entity\EntityDisplayBase->__sleep() #7 [internal function]: session_write_close() #8 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/localhost/web/core/lib/Drupal/Core/Entity/EntityTypeManager.php on line 139

1 Answer 1

3

This looks like you still have a display mode object stored in the user session referencing the media entity type. Unserializing this object throws the error message. Log out and log in, if more users are affected then truncate the sessions table.

2
  • OMG, it works. I was searching and troubleshooting for days about this issue. Thanks!
    – CocoSkin
    Jul 27, 2023 at 19:12
  • 1
    For those who have the same issue. You can run the Drush command to log out everyone. This command will empty the "sessions" table in database. drush sql-query 'TRUNCATE TABLE sessions;'
    – CocoSkin
    Jul 27, 2023 at 20:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.