Hi,

deleting the view of a bock field causes an error upon accessing the content using the referenced field:

"The website encountered an unexpected error"

It would be nice to have better information on the source of an error like that, in order to troubleshoot more easily.

The log shows:

TypeError: Argument 1 passed to Drupal\views\ViewExecutableFactory::get() must implement interface Drupal\views\ViewEntityInterface, null given, called in /web/core/modules/views/src/Plugin/Block/ViewsBlockBase.php on line 69 in Drupal\views\ViewExecutableFactory->get() (line 70 of /web/core/modules/views/src/ViewExecutableFactory.php) #0 /web/core/modules/views/src/Plugin/Block/ViewsBlockBase.php(69): Drupal\views\ViewExecutableFactory->get(NULL) #1 /web/core/modules/views/src/Plugin/Block/ViewsBlockBase.php(84): Drupal\views\Plugin\Block\ViewsBlockBase->__construct(Array, 'views_block:v_d...', Array, Object(Drupal\views\ViewExecutableFactory), Object(Drupal\Core\Config\Entity\ConfigEntityStorage), Object(Drupal\Core\Session\AccountProxy)) #2 /web/core/lib/Drupal/Core/Plugin/Factory/ContainerFactory.php(21): Drupal\views\Plugin\Block\ViewsBlockBase::create(Object(Drupal\Core\DependencyInjection\Container), Array, 'views_block:v_d...', Array) #3 /web/core/lib/Drupal/Component/Plugin/PluginManagerBase.php(76): Drupal\Core\Plugin\Factory\ContainerFactory->createInstance('views_block:v_d...', Array) #4 /web/modules/ds/src/Plugin/DsField/BlockBase.php(120): Drupal\Component\Plugin\PluginManagerBase->createInstance('views_block:v_d...') #5 /web/modules/ds/src/Plugin/DsField/BlockBase.php(76): Drupal\ds\Plugin\DsField\BlockBase->getBlock() #6 /web/modules/ds/ds.module(234): Drupal\ds\Plugin\DsField\BlockBase->build() #7 /web/core/lib/Drupal/Core/Extension/ModuleHandler.php(501): ds_entity_view_alter(Array, Object(Drupal\node\Entity\Node), Object(Drupal\Core\Entity\Entity\EntityViewDisplay)) #8 /web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(284): Drupal\Core\Extension\ModuleHandler->alter('node_view', Array, Object(Drupal\node\Entity\Node), Object(Drupal\Core\Entity\Entity\EntityViewDisplay)) #9 /web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(219): Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array) #10 [internal function]: Drupal\Core\Entity\EntityViewBuilder->build(Array) #11 /web/core/lib/Drupal/Core/Render/Renderer.php(376): call_user_func(Array, Array) #12 /web/core/lib/Drupal/Core/Render/Renderer.php(195): Drupal\Core\Render\Renderer->doRender(Array, false) #13 /web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(226): Drupal\Core\Render\Renderer->render(Array, false) #14 /web/core/lib/Drupal/Core/Render/Renderer.php(574): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() #15 /web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(227): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #16 /web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(117): Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch)) #17 /web/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch)) #18 /web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object(Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher)) #19 /web/vendor/symfony/http-kernel/HttpKernel.php(149): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object(Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent)) #20 /web/vendor/symfony/http-kernel/HttpKernel.php(64): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #21 /web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #22 /web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #23 /web/core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #24 /web/core/modules/page_cache/src/StackMiddleware/PageCache.php(78): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #25 /web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #26 /web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(50): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #27 /web/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #28 /web/core/lib/Drupal/Core/DrupalKernel.php(652): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #29 /web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #30 {main}.

CommentFileSizeAuthor
#2 2852569-2.patch2.58 KBaspilicious
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

maxilein created an issue. See original summary.

aspilicious’s picture

Status: Active » Needs review
FileSize
2.58 KB

I have a partial fix for the problem.
But there is also a core bug, views doesn't clear the block caches when a view gets deleted.

aspilicious’s picture

Project: Display Suite » Drupal core
Version: 8.x-2.6 » 8.4.x-dev
Component: Code » views.module
Status: Needs review » Needs work

In fact my patch isn't needed. The problem is that views should clear the block caches when a view gets deleted.
Moving to core.

Once you cleared the caches: "This block is broken or missing. You may be missing content or you might need to enable the original module."

dawehner’s picture

For me this sounds like something in the chain of systems doesn't expose/use config dependencies properly.

\Drupal\views\Plugin\Derivative\ViewsBlock::getDerivativeDefinitions seems to do that and \Drupal\views\Plugin\Derivative\ViewsExposedFilterBlock too, mhhh

Berdir’s picture

bock field causes an error upon accessing the content using the referenced field:

I assume that should say block field, which means it is https://www.drupal.org/project/block_field, which means *content*, so the config dependency system obviously doesn't work :)

maxilein’s picture

@ Berdir: you are mistaken: I refer to the block field of display suite. The ones you can create under admin/structure/ds/fields

aspilicious’s picture

Berdir the problem is that the blockmanager hasdefintion method returns TRUE whenthe view is JUST deleted. So when you call "createInstance" in code with such a views block ID, it crashes. After clearing the caches you get a proper warning.

"This block is broken or missing. You may be missing content or you might need to enable the original module."

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.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.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.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.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.

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.

quietone’s picture

Status: Needs work » Closed (cannot reproduce)
Issue tags: +Bug Smash Initiative

@maxilein, Thank you for reporting this problem. We rely on issue reports like this to improve Drupal core.

I tested this on 9.4.x, standard install, and was not able to reproduce this error. I created a block view and added it to all pages. Load a page and see the block view. Then deleted the block, loaded a page and the view was not there and no error messages.

Therefore, closing as cannot reproduce. If you are experiencing this problem on a supported version of Drupal reopen the issue, by setting the status to 'Active', and provide complete steps to reproduce the issue (starting from "Install Drupal core").

Thanks!