Closed (fixed)
Project:
Easy Breadcrumb
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
23 Nov 2017 at 07:22 UTC
Updated:
19 Apr 2018 at 09:25 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
gargsuchi commentedComment #3
gargsuchi commentedComment #4
gg24 commentedHi @gargsuchi,
I have tested the above patch. It applies cleanly but If the current route is an admin route than $title returns an object but if the $title is a string which is the case of non-admin route than directly applying getUntranslatedString() throws an error. In that case I am checking if it is an object than apply the method else fetch the $title using $this->titleResolver->getTitle().
Please review the patch.
Thanks!
Comment #6
gg24 commentedComment #7
gg24 commentedComment #8
guptahemant commentedhi @gg24,
I have applied your patch in #6 ,it applies cleanly and resolves the mentioned issue,Hence marking the issue as RTBC.
Steps followed are:
1. Installed the module.
2. Gone to configuration form and saved the settings.(This didn't produce the issue)
3. Then I enabled "Use the real page title when available" option and the issue appears as mentioned.
4. Then I applied the patch and it resolves the warning.
5. Tested again by enabling and disabling "Use the real page title when available" this option
Thanks,
Comment #9
gargsuchi commentedMinor nitpick - fixed a typo in the comment and also shortened the comment.
Comment #11
gargsuchi commentedComment #12
greg boggsLooks good! Thanks Gargsuchi!
Comment #13
gargsuchi commentedComment #14
replicaobscuraI'm still getting this same error on most admin pages when using the latest patch here. I no longer get it multiple times, but I still get it one time on each page the first time it's loaded. I verified the patch is applied and the code it introduces is present, but there must still be a way that $title is not a string when it gets through:
Warning: array_key_exists(): The first argument should be either a string or an integer in Drupal\easy_breadcrumb\EasyBreadcrumbBuilder->build() (line 219 of modules/easy_breadcrumb/src/EasyBreadcrumbBuilder.php).I'm not sure what could cause this yet.
Comment #15
greg boggsWanna do a screen share?
Comment #16
greg boggsWhat we're going to want to do is to set a break point on line 219.
For that to work you need:
1. PHP installed locally with the site installed.
2. Xdebug installed
3. PHPStorm or any other free IDE like netbeans.
4. Xdebug configured in your IDE.
Then we set the break point, load the page and see what the value of the variable is.
Comment #17
replicaobscuraActually, I believe I must have been experiencing some sort of Pantheon issue with the old version of the file still being in place somehow. I can't seem to reproduce the issue in my local development environment. If I can reproduce the issue again, I'll let you know what the value of
$titleis when the issue occurs. But in the meantime, it seems this should probably still be RTBC. Thanks!Comment #18
martin.davidson commentedI'm on a menu admin screen (/admin/structure/menu/manage/main) with the patch enabled, and I'm getting
Warning: array_key_exists(): The first argument should be either a string or an integer in Drupal\easy_breadcrumb\EasyBreadcrumbBuilder->build() (line 213 of modules/contrib/easy_breadcrumb/src/EasyBreadcrumbBuilder.php).When I throw a breakpoint there, this is what the $title variable is:
Doesn't look like the patch is expecting an array. Is it as simple as checking if it's an array and seeing if there's a #markup key? I don't have enough context.
Comment #19
martin.davidson commentedComment #20
replicaobscuraHere's another attempt.
First, is_object() is too generic I believe--so I'm using instanceof to make sure it's got the method that we actually need.
Second, as discovered it could be an array with a #markup key containing the string, so I've accounted for that.
Third, I've ensured it's a string before trying to use it with is_string in case one of the conditionals did not convert it to a proper title.
This is working for me in all cases I've tested so far.
Comment #21
loopduplicate commentedHere's an interdiff between #11 and #20.
Comment #22
greg boggs@loop,
What do you think, can you commit and push what you believe is the correct solution? :)
Comment #23
loopduplicate commented@greg working on it
Comment #24
loopduplicate commentedHere's an updated patch with a bit more commenting. It also includes a log message if another type of data is encountered.
I've included an interdiff between 20 and 24.
Comment #25
greg boggsThat looks correct.
Comment #26
loopduplicate commentedOK, marking as RTBC and will get this committed to the dev branch. Let's credit all contributors to this issue. Thanks :)
Comment #28
loopduplicate commentedComment #30
Christopher Riley commentedI am getting the same error when I install Search API and try to edit the default content index. Here is the trace:
Warning: array_key_exists(): The first argument should be either a string or an integer in Drupal\easy_breadcrumb\EasyBreadcrumbBuilder->build() (line 229 of modules/contrib/easy_breadcrumb/src/EasyBreadcrumbBuilder.php).
Drupal\easy_breadcrumb\EasyBreadcrumbBuilder->build(Object) (Line: 83)
Drupal\Core\Breadcrumb\BreadcrumbManager->build(Object) (Line: 72)
Drupal\system\Plugin\Block\SystemBreadcrumbBlock->build() (Line: 203)
Drupal\block\BlockViewBuilder::preRender(Array)
call_user_func('Drupal\block\BlockViewBuilder::preRender', Array) (Line: 378)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 450)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 490)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 59)
__TwigTemplate_f8a17f041581af9829850fd45db45c2b69d8b3a60b80408d416da5d23dbccb61->doDisplay(Array, Array) (Line: 432)
Twig_Template->displayWithErrorHandling(Array, Array) (Line: 403)
Twig_Template->display(Array) (Line: 411)
Twig_Template->render(Array) (Line: 64)
twig_render_template('core/themes/seven/templates/page.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('page', Array) (Line: 437)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 490)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 90)
__TwigTemplate_be8c7bbb9c824f2826368d7c8da984c6279779db72a67fd8056a00bb23b816f2->doDisplay(Array, Array) (Line: 432)
Twig_Template->displayWithErrorHandling(Array, Array) (Line: 403)
Twig_Template->display(Array) (Line: 411)
Twig_Template->render(Array) (Line: 64)
twig_render_template('core/themes/classy/templates/layout/html.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('html', Array) (Line: 437)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 147)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 148)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 156)
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: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 657)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Suggestions?
Comment #31
tim-dielsHi Christopher Riley,
Please take a look at https://www.drupal.org/project/easy_breadcrumb/issues/2960546
This is almost the same issue and the patch solves the problem.