Problem/Motivation

cookiebot_preprocess_menu() runs for every menu on the site and calls $item['url']toString(), assuming $item['url'] is always a \Drupal\Core\Url object. It isn't always, some menus expose url as a plain string.
Gin admin theme, whose "Content" navigation region builds menu items with a string url (e.g. Url::fromRoute('system.admin_content')toString()), so admin pages crash.

Steps to reproduce

Enable Cookiebot and set a Cookiebot ID.
Use the Gin theme as the admin theme.
Visit /admin/conten
The page errors with "Call to a member function toString() on string".

Proposed resolution

Only call toString() when $item['url'] is actually a \Drupal\Core\Url object.
Non-Url items are safely skipped (they can never match /cookiebot-renew), so no behaviour changes.

Issue fork cookiebot-3601092

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rafaellapinho created an issue. See original summary.

bramdriesen’s picture

Status: Active » Needs review

Setting to NR as there is a MR created?

bramdriesen’s picture

Status: Needs review » Needs work

Small nitpick by phpcs, the rest was already there.

anybody made their first commit to this issue’s fork.

santanu mondal made their first commit to this issue’s fork.

santanu mondal’s picture

Status: Needs work » Needs review