Same bug result as described in #2925736: Warning: array_key_exists(): The first argument should be either a string or an integer in Drupal\easy_breadcrumb\EasyBreadcrumbBuilder->build()

Warning: array_key_exists(): The first argument should be either a string or an integer in Drupal\easy_breadcrumb\EasyBreadcrumbBuilder->build() (line 240 of /<path to docroot>/modules/contrib/easy_breadcrumb/src/EasyBreadcrumbBuilder.php)

This issue, fixes that for cases where the title is a FormattableMarkup object

Comments

NickWilde created an issue. See original summary.

nickdickinsonwilde’s picture

Assigned: nickdickinsonwilde » Unassigned
Status: Active » Needs review
StatusFileSize
new1005 bytes

The patch, simple, not must to say.
Specifically, ensures that it works with the Search API/hosted apache solr module.

greg boggs’s picture

Thanks Nick. Can I just say, I am disappointed with how difficult it is to implement getTitle().

How do I test this? Meaning, what does it take to generate a return that is a formattable markup object? Off topic but do you know if there's a core issue for get Title to return the same type of object?

nickdickinsonwilde’s picture

Assigned: Unassigned » nickdickinsonwilde
Status: Needs review » Needs work
Issue tags: +Needs tests

Ah you're right, I'll stop being lazy Greg... test coming up. I at least have an example in contrib on one project at least of how to make a FormattableMarkup object return there, so a good start.

It really does seem excessively difficult to be getting exactly what you need.

greg boggs’s picture

Feel free to link me to the contrib, or just drop some code in that I can use for testing. I'm ok with a manual test. But, we've had *a lot* of trouble getting a page title. Like this one: https://www.drupal.org/project/drupal/issues/2960223. So, I want to make sure I know how to test each piece.

nickdickinsonwilde’s picture

Assigned: nickdickinsonwilde » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new9.96 KB

Here's a set of tests and an extra fix for getting the title string - not all render array's have #allowed_tags as a key.
To make it easier to test, I split getting the title string out of build() as a new function.
The test class probably should make use of a setUp() method instead of creating the breadcrumb stuff in each test method but works for now. At least locally... we'll see what the ci says.

Ended up getting busy this weekend, but got to it as I was cleaning up for my work week.

tim-diels’s picture

Tested the latest patch, and works for me.

olivier.bouwman’s picture

I experienced the same error, patch #6 resolved it. Thank you!

  • Greg Boggs committed 4d2df56 on 8.x-1.x authored by NickWilde
    Issue #2960546 by NickWilde, Greg Boggs, tim-diels, olivier.bouwman:...
greg boggs’s picture

greg boggs’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.