As of 2.0.3: "Warning: array_key_exists(): The first argument should be either a string or an integer" when encountering page titled via TranslatableMarkup

Created on 29 June 2022, over 2 years ago
Updated 13 April 2023, over 1 year ago

After upgrading from 2.0.2 to 2.0.3, I encountered a type of a page on the site generating this error message at the top:

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

This site in question and its configuration are all pretty new to me, but it seemed to be showing on "result" pages provided by the drupal/quiz (example URL apparently being something like /quiz/4/result/455) and I was able to run a quick ksm($title) after line 490 that revealed that it's likely that TranslatableMarkup and its use of arguments to form the page title was presumably part of the culprit here:

Presumably of course newly in 2.0.3 via #3272480: Titles to be replaced while generating segments doesn't work in all the scenarios β†’ .

Sorry that at the moment I don't know (or didn't have time to figure out) a number of things (much less attempt to work on a patch), including:

  • If the same kind of problem happens with other kinds of objects beyond just TranslatableMarkup or other cases that might also affected by passing argument values or whatever
  • What all the context/conditions/functionality around line 492 are, and whether other areas of the code might be similarly affected
  • If quiz is doing something to cause this that they shouldn't be doing on their end (but ... shrug? since other contrib or custom modules might be doing something similar anyway, and I'd assume (maybe incorrectly?) that easy_breadcrumb could perhaps fail or otherwise deal with this kind of case more gracefully?)

Thanks!

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States maxstarkenburg Washington, DC

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • I agree with MegaChriz that it looks like there went something wrong in the merge, but I think the
    $title = (string) $entity->label();
    is the redundant one, since the getTitleString()-method also considers Breadcrumb-Overrides (which would be overridden by the entity-label afterwards.

  • I agree with MegaChriz that it looks like there went something wrong in the merge, but I think the
    $title = (string) $entity->label();
    is the redundant one, since the getTitleString()-method also considers Breadcrumb-Overrides (which would be overridden by the entity-label afterwards.

Production build 0.71.5 2024