System: Drupal 8.7 with entity_browser 1.8.0
We have some entries in database table media_field_data that are not in table media.
When opening the entity browser to select an image, a crash occurs:
The website encountered an unexpected error. Please try again later. Error: Call to a member function getEntityTypeId() on null in Drupal\entity_browser\Plugin\views\field\SelectForm->getRowId() (line 29 of modules/contrib/entity_browser/src/Plugin/views/field/SelectForm.php).
Delete all the broken media entries.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | DELETE FROM media_field_data WHERE mid IN ( SELECT mid FROM ( SELECT media_field_data.mid FROM `media_field_data` LEFT JOIN media ON media_field_data.mid = media.mid WHERE media.mid IS NULL ) AS foo ); DELETE FROM media_field_revision WHERE mid IN ( SELECT mid FROM ( SELECT media_field_revision.mid FROM `media_field_revision` LEFT JOIN media ON media_field_revision.mid = media.mid WHERE media.mid IS NULL ) AS foo ); |
The website encountered an unexpected error. Please try again later. Error: Call to a member function getEntityTypeId() on null in Drupal\entity_browser\Plugin\views\field\SelectForm->getRowId() (line 29 of modules/contrib/entity_browser/src/Plugin/views/field/SelectForm.php). Drupal\entity_browser\Plugin\views\field\SelectForm->getRowId(Object) (Line: 36) Drupal\entity_browser\Plugin\views\field\SelectForm->render(Object) (Line: 1155) Drupal\views\Plugin\views\field\FieldPluginBase->advancedRender(Object) (Line: 236) template_preprocess_views_view_field(Array, 'views_view_field', Array) (Line: 287) Drupal\Core\Theme\ThemeManager->render('views_view_field', Array) (Line: 437) Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195) Drupal\Core\Render\Renderer->render(Array) (Line: 1747) Drupal\views\Plugin\views\field\FieldPluginBase->theme(Object) (Line: 761) Drupal\views\Plugin\views\style\StylePluginBase->elementPreRenderRow(Array) call_user_func(Array, Array) (Line: 378) Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195) Drupal\Core\Render\Renderer->render(Array) (Line: 709) Drupal\views\Plugin\views\style\StylePluginBase->renderFields(Array) (Line: 576) Drupal\views\Plugin\views\style\StylePluginBase->renderGrouping(Array, Array, 1) (Line: 468) Drupal\views\Plugin\views\style\StylePluginBase->render(Array) (Line: 2111) Drupal\views\Plugin\views\display\DisplayPluginBase->render() (Line: 131) Drupal\webprofiler\Views\TraceableViewExecutable->render() (Line: 33) Drupal\entity_browser\Plugin\views\display\EntityBrowser->execute() (Line: 104) Drupal\entity_browser\Plugin\views\display\EntityBrowser->preview() (Line: 1662) Drupal\views\ViewExecutable->preview('entity_browser_1', Array) (Line: 194) Drupal\views\Controller\ViewAjaxController->Drupal\views\Controller\{closure}() (Line: 582) Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 195) Drupal\views\Controller\ViewAjaxController->ajaxView(Object) 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: 67) Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->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: 38) Drupal\webprofiler\StackMiddleware\WebprofilerMiddleware->handle(Object, 1, 1) (Line: 52) Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23) Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693) Drupal\Core\DrupalKernel->handle(Object) (Line: 19)