htmlspecialchars() expects parameter 1 to be string

Created on 5 November 2021, over 2 years ago
Updated 10 February 2023, over 1 year ago

Problem/Motivation

Warning: htmlspecialchars() expects parameter 1 to be string, array given in Drupal\Component\Utility\Html::escape() (line 424 of /var/www/html/web/core/lib/Drupal/Component/Utility/Html.php)

The $title parameter is sometimes specified with an array. See src/Plugin/Block/SocialSharingButtonsBlock.php on line 179.

if ($route = $request->attributes->get(RouteObjectInterface::ROUTE_OBJECT)) {
$title = $this->titleResolver->getTitle($request, $route);
}
+ if (isset($title['#markup'])) {
+ $title = $title['#markup'];
+ }

Steps to reproduce

A page with a $title array with the '#markup' element.

Proposed resolution

See Patch.

Remaining tasks

Review patch.

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Fixed

Version

3.2

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium tomhollevoet

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.

Production build 0.69.0 2024