Problem/Motivation
I got an error on the user page
got to the page /user/1
TypeError: strip_tags(): Argument #1 ($string) must be of type string, array given in strip_tags() (line 181 of /var/www/my-site.com/htdocs/themes/january_theme/january.theme).
Fresh installed Drupal 10.1.2 and January theme 1.0.1 and also tried with 1.0.x-dev
go to page /user/1
Steps to reproduce
1. Fresh installed Drupal 10.1.2
2. Install january_theme 1.0.1 or 1.0.x-dev
3. Go to the page /user/1
Proposed resolution
$title = \Drupal::service('title_resolver')->getTitle($request, $route);
$variables['page__title']=strip_tags($title);
$title = \Drupal::service('title_resolver')->getTitle($request, $route);
var_dump($title);die;
Result for the home page
string(10) "Front page"
Result for /user/1
array(2) { ["#markup"]=> string(5) "admin" ["#allowed_tags"]=> array(12) { [0]=> string(1) "a" [1]=> string(2) "em" [2]=> string(6) "strong" [3]=> string(4) "cite" [4]=> string(10) "blockquote" [5]=> string(4) "code" [6]=> string(2) "ul" [7]=> string(2) "ol" [8]=> string(2) "li" [9]=> string(2) "dl" [10]=> string(2) "dt" [11]=> string(2) "dd" } }
Make a check on $title is a String or an array
if (is_string($title)) {
$variables['page__title']=strip_tags($title);
}
elseif (is_array($title)) {
$variables['page__title']=strip_tags($title['#markup']);
}
else {
$variables['page__title'] = "";
}
Patch attached