After attempting an upgrade of Drupal from 8.5.x to 8.7.x I am now receiving the error:

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

whenever I attempt to make any changes to the index config.

Comments

cap60552 created an issue. See original summary.

mkalkbrenner’s picture

Project: Search API Solr » Search API
Version: 8.x-2.x-dev » 8.x-1.x-dev
Component: Code » General code
drunken monkey’s picture

Status: Active » Postponed (maintainer needs more info)

Do you have a stack trace for this error? (Can be enabled at /admin/config/development/logging if Devel module is installed (or maybe even without).)
Does your index contain media entities?

wblancditjolicoeur’s picture

Hi,
I got the same behaviour when trying to upgrade from search_api_solr 1.x to 3.x ( here from 1.3 to 3.8) while still using the contrib "Media Entity" Module 8.x-1.8.

Of course, Media are meant to be indexed.

any action on /admin/config/search/search-api/index/index_name/edit, /admin/config/search/search-api/index/index_name/fields ,
or drush sapi-c, sapi-r sapi-i will result in the following trace :

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "media_type" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 150 of core/lib/Drupal/Core/Entity/EntityTypeManager.php).

Drupal\Core\Entity\EntityTypeManager->getHandler('media_type', 'storage') (Line: 208)
Drupal\Core\Entity\EntityTypeManager->getStorage('media_type') (Line: 484)
Drupal\search_api_attachments\Plugin\search_api\processor\FilesExtractor->getFileFieldsAndFileEntityItems() (Line: 163)
Drupal\search_api_attachments\Plugin\search_api\processor\FilesExtractor->getPropertyDefinitions(NULL) (Line: 844)
Drupal\search_api\Entity\Index->getPropertyDefinitions(NULL) (Line: 434)
Drupal\search_api\Item\Field->getDataDefinition() (Line: 114)
Drupal\search_api\Plugin\search_api\processor\AddHierarchy->getHierarchyFields() (Line: 91)
Drupal\search_api\Plugin\search_api\processor\AddHierarchy::supportsIndex(Object)
call_user_func(Array, Object) (Line: 371)
Drupal\search_api\Form\IndexProcessorsForm->getAllProcessors() (Line: 103)
Drupal\search_api\Form\IndexProcessorsForm->form(Array, Object) (Line: 149)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 520)
Drupal\Core\Form\FormBuilder->retrieveForm('search_api_index_processors_form', Object) (Line: 277)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 91)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 573)
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: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 694)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Is there any quick workaround to this ? Or should I definitly urge to switch to Media Entity in core ?

drunken monkey’s picture

Component: General code » Plugins
Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new3.09 KB

Brilliant, thanks a lot for the backtrace! Seems the flaw we need to fix in this module is insufficient error handling in the “Add hierarchy” processor. Please see, test and review the attached patch!

However, from the stack trace it’s apparent that there is also an underlying issue in the Search API Attachments module, so I posted a patch there was well: #3117949: Improve exception handling in FilesExtractor. Would be great if you could review that patch (independently of this one), too! Would be great to get both of these fixed.

drunken monkey’s picture

PS: Hm, looking at this again, as the FilesExtractor::getPropertyDefinitions() method doesn’t follow its contract, by propagating/throwing exceptions it shouldn’t, the patch here wouldn’t actually do anything to resolve your problem. It should still be an improvement, but you’ll probably need the Attachments patch for the problem to go away.

  • drunken monkey committed 4bb7183 on 8.x-1.x
    Issue #3056940 by drunken monkey: Fixed error handling in the "Add...
drunken monkey’s picture

Status: Needs review » Fixed

Committed.
If possible, please still also give feedback on the Attachments patch in #3117949: Improve exception handling in FilesExtractor. (As said, the commit here will most likely not help with your problem.)

Status: Fixed » Closed (fixed)

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