Score:0

PluginNotFoundException entity type does not exist when trying to uninstall any module

cn flag

I've got this drupal website from a client that the another developer created, and they've made a mess with many things in this site. I'm having a problem where every time I try to uninstall a module, this error appears:

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

Apparently there was a module "block_content" installed before. This module is uninstalled. So I've tried removing anything that could be causing this problem. So far I've tried:

removing the module from core.extension:

$moduleData = \Drupal::config('core.extension')->get('module');
unset($moduleData[$module]);
\Drupal::configFactory()->getEditable('core.extension')->set('module', $moduleData)->save();

This config was detected, and it was removed, but still this problem continues.

removed the module from system.schema:

$systemSchema = \Drupal::keyValue('system.schema');
$systemSchema->delete($module);

Also this config was detected, and it was removed, but still having the problem.

when trying to get the entity_type...

\Drupal::entityDefinitionUpdateManager()->getEntityType($entity_type)

The return is null; off course because the entity type does not exist and its not found.

So, what can I do to solve this issue? Can you point me to the right direction? It seems there is still a config pointing to this entity type, and drupal is not finding it.

Edit

I've added the full error message when trying to uninstall the redirect module:

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "block_content" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 150 of core\lib\Drupal\Core\Entity\EntityTypeManager.php).
Drupal\Core\Entity\EntityFieldManager->buildBaseFieldDefinitions('block_content') (Line: 179)
Drupal\Core\Entity\EntityFieldManager->getBaseFieldDefinitions('block_content') (Line: 436)
Drupal\Core\Entity\EntityFieldManager->getFieldStorageDefinitions('block_content') (Line: 296)
Drupal\field\Entity\FieldConfig->getFieldStorageDefinition() (Line: 145)
Drupal\field\FieldConfigStorage->loadByProperties(Array) (Line: 220)
field_entity_bundle_delete('redirect', 'redirect')
call_user_func_array('field_entity_bundle_delete', Array) (Line: 403)
Drupal\Core\Extension\ModuleHandler->invokeAll('entity_bundle_delete', Array) (Line: 85)
Drupal\Core\Entity\EntityBundleListener->onBundleDelete('redirect', 'redirect') (Line: 423)
Drupal\Core\Extension\ModuleInstaller->uninstall(Array, 1) (Line: 91)
Drupal\Core\ProxyClass\Extension\ModuleInstaller->uninstall(Array) (Line: 183)
Drupal\system\Form\ModulesUninstallConfirmForm->submitForm(Array, Object)
call_user_func_array(Array, Array) (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 593)
Drupal\Core\Form\FormBuilder->processForm('system_modules_uninstall_confirm_form', Array, Object) (Line: 321)
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: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

I've also reverted the database to a version before my tries, and when running the code $entityType = $entityUpdateManager->getEntityType($entity_type); it finds "block_content", but when trying to run this command $entityUpdateManager->uninstallEntityType($entityType); it shows an error caught in the try catch (I've omitted the directories):

error: Drupal\Component\Plugin\Exception\PluginNotFoundException: The "block_content" entity type does not exist. in ...\core\lib\Drupal\Core\Entity\EntityTypeManager.php:150 ◀
Stack trace:
#0 ...\core\modules\views\src\Entity\View.php(335): Drupal\Core\Entity\EntityTypeManager->getDefinition('block_content')
#1 ...\core\modules\views\src\Entity\View.php(300): Drupal\views\Entity\View->fixTableNames(Array)
#2 ...\core\lib\Drupal\Core\Entity\EntityStorageBase.php(499): Drupal\views\Entity\View->preSave(Object(Drupal\Core\Config\Entity\ConfigEntityStorage)) ◀
#3 ...\core\lib\Drupal\Core\Entity\EntityStorageBase.php(454): Drupal\Core\Entity\EntityStorageBase->doPreSave(Object(Drupal\views\Entity\View)) ◀
#4 ...\core\lib\Drupal\Core\Config\Entity\ConfigEntityStorage.php(263): Drupal\Core\Entity\EntityStorageBase->save(Object(Drupal\views\Entity\View)) ◀
#5 ...\core\lib\Drupal\Core\Entity\EntityBase.php(395): Drupal\Core\Config\Entity\ConfigEntityStorage->save(Object(Drupal\views\Entity\View)) ◀
#6 ...\core\lib\Drupal\Core\Config\Entity\ConfigEntityBase.php(616): Drupal\Core\Entity\EntityBase->save()
#7 ...\core\modules\views\src\EventSubscriber\ViewsEntitySchemaSubscriber.php(265): Drupal\Core\Config\Entity\ConfigEntityBase->save() ◀
#8 ...\core\lib\Drupal\Core\Entity\EntityTypeEventSubscriberTrait.php(51): Drupal\views\EventSubscriber\ViewsEntitySchemaSubscriber->onEntityTypeDelete(Object(Drupal\Core\Entity\ContentEntityType)) ◀
#9 [internal function]: Drupal\views\EventSubscriber\ViewsEntitySchemaSubscriber->onEntityTypeEvent(Object(Drupal\Core\Entity\EntityTypeEvent), 'entity_type.def...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher)) ◀
#10 ...\core\lib\Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Drupal\Core\Entity\EntityTypeEvent), 'entity_type.def...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher)) ◀
#11 ...\core\lib\Drupal\Core\Entity\EntityTypeListener.php(145): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('entity_type.def...', Object(Drupal\Core\Entity\EntityTypeEvent)) ◀
#12 ...\core\lib\Drupal\Core\Entity\EntityDefinitionUpdateManager.php(215): Drupal\Core\Entity\EntityTypeListener->onEntityTypeDelete(Object(Drupal\Core\Entity\ContentEntityType)) ◀
#13 ...\modules\custom\{module_for_testing}\src\Controller\RepairController.php(21): Drupal\Core\Entity\EntityDefinitionUpdateManager->uninstallEntityType(Object(Drupal\Core\Entity\ContentEntityType)) ◀
#14 [internal function]: Drupal\{module_for_testing}\Controller\RepairController->removeEntityType('block_content')
#15 ...\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) ◀
#16 ...\core\lib\Drupal\Core\Render\Renderer.php(573): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() ◀
#17 ...\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) ◀
#18 ...\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) ◀
#19 ...\vendor\symfony\http-kernel\HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() ◀
#20 ...\vendor\symfony\http-kernel\HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) ◀
#21 ...\core\lib\Drupal\Core\StackMiddleware\Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) ◀
#22 ...\core\lib\Drupal\Core\StackMiddleware\KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) ◀
#23 ...\core\modules\page_cache\src\StackMiddleware\PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) ◀
#24 ...\core\modules\page_cache\src\StackMiddleware\PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) ◀
#25 ...\core\lib\Drupal\Core\StackMiddleware\ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) ◀
#26 ...\core\lib\Drupal\Core\StackMiddleware\NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) ◀
#27 ...\vendor\stack\builder\src\Stack\StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) ◀
#28 ...\core\lib\Drupal\Core\DrupalKernel.php(708): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) ◀
#29 ...\index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#30 {main}
4uk4 avatar
cn flag
In case of a missing plugin you need a full error message, with backtrace information, to track the code calling EntityTypeManager::getDefinition().
Jean da Silva avatar
cn flag
@4uk4 I've added the error messages
Jaypan avatar
de flag
Try enabling then re-uninstalling the Custom Block module that ships with core.
Jean da Silva avatar
cn flag
I don't know how to solve it, I've tried what @jaypan suggested but it is still appearing. When I try to run update.php, it shows this error: `Drupal\Component\Plugin\Exception\PluginNotFoundException: The "block_content" entity type does not exist. In function Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 139 from file ...\docroot\core\lib\Drupal\Core\Entity\EntityTypeManager.php)` .I've disabled modules "block_content" and "block" manually by unseting from "core.extension" and "system.schema".
Jaypan avatar
de flag
It sounds like you have code somewhere else that is calling the custom block module. Maybe just enable that and lave it enabled. Or, you'll need to figure out which of your code is trying to insert a custom block into your system. Custom modules/themes are a likely culprit.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.