From b36c208cc2b14b2ac0a26d6900e7ce0e46a2bda7 Mon Sep 17 00:00:00 2001 From: Barry Fisher <34511-reallifedesign@users.noreply.drupalcode.org> Date: Fri, 23 Sep 2022 23:40:53 +0500 Subject: [PATCH] Issue #3260248 by Barry_Fisher: BlockViewBuilder error prevents cron from running when called from CLI --- src/View/BlockViewBuilder.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/View/BlockViewBuilder.php b/src/View/BlockViewBuilder.php index 440d83d..fd1545c 100644 --- a/src/View/BlockViewBuilder.php +++ b/src/View/BlockViewBuilder.php @@ -121,9 +121,14 @@ class BlockViewBuilder { if ($access->isAllowed()) { // Title block needs a special treatment. if ($block_plugin instanceof TitleBlockPluginInterface) { - $request = $this->requestStack->getCurrentRequest(); - $title = $this->titleResolver->getTitle($request, $this->routeMatch->getRouteObject()); - $block_plugin->setTitle($title); + // Account for the scenario that a NullRouteMatch is returned. This, for + // example, is the case when Search API is indexing the site during + // Drush cron. + if ($route = $this->routeMatch->getRouteObject()) { + $request = $this->requestStack->getCurrentRequest(); + $title = $this->titleResolver->getTitle($request, $route); + $block_plugin->setTitle($title); + } } // Place the content returned by the block plugin into a 'content' child