# Issue: radix_preprocess_links__dropbutton() passes render array to strlen() causing fatal error on Drupal 11.4

**Project:** Radix
**Issue type:** Bug
**Drupal core:** 11.4.x

## Summary

A fatal PHP TypeError occurs when rendering any page that contains a dropbutton element (such as node edit pages, content listings etc.) because `radix_preprocess_links__dropbutton()` passes a render array to `Xss::filter()` which internally calls `strlen()`. In PHP 8.x, `strlen()` requires a string argument and throws a fatal error when passed an array.

## Steps to reproduce

1. Install Drupal 11.4.x with Radix as the active theme (or a Radix subtheme)
2. Navigate to any page that renders a dropbutton — e.g. a node page, `/admin/content`, or any page with entity operations
3. Observe fatal TypeError

## Error message

```
TypeError: strlen(): Argument #1 ($string) must be of type string, array given
in strlen() (line 401 of core/lib/Drupal/Component/Utility/Unicode.php).

radix_preprocess_links__dropbutton() (Line: 523)
Drupal\Core\Theme\ThemeManager->invoke()
```

## Root cause

In `includes/menu.theme` around line 79, the `$link['text']` value is passed directly to `Xss::filter()`:

```php
'text' => isset($link['text']) ? htmlspecialchars_decode(Xss::filter($link['text'])) : '',
```

In Drupal 11.4.x, `$link['text']` can be a render array rather than a plain string. `Xss::filter()` passes its argument to `Unicode::validateUtf8()` which calls `strlen()`, which in PHP 8.x requires a string and throws a fatal TypeError when given an array.

## Fix

Check whether `$link['text']` is an array before passing it to `Xss::filter()`, and if so render it first using the renderer service:

```php
'text' => isset($link['text']) ? htmlspecialchars_decode(Xss::filter(
is_array($link['text'])
? \Drupal::service('renderer')->renderInIsolation($link['text'])
: $link['text']
)) : '',
```

Note: The deprecated `render()` procedural function must not be used as it was removed in Drupal 11.

This fix has been tested and confirmed to resolve the issue on Drupal 11.4.x with PHP 8.3.

## Additional context

This issue affects any Radix subtheme on Drupal 11.4.x and will be encountered on any page that renders dropbutton elements, which includes most standard Drupal admin and content pages. It is a blocking issue for new Drupal 11.4.x installations using Radix.

Issue fork radix-3592513

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

paulwoodhead created an issue. See original summary.

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

paulwoodhead’s picture

Status: Active » Needs review

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

  • doxigo committed fbcfd753 on 6.0.x authored by paulwoodhead
    Issue #3592513 by paulwoodhead, hoxton: Render link text array before...
doxigo’s picture

Status: Needs review » Fixed

Thanks Paul, this is merged 🙌

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

paulwoodhead’s picture

Coolio and no worries 😉👍🍻

liam morland’s picture

Issue tags: -PHP 8 +PHP 8.0

Status: Fixed » Closed (fixed)

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