Prevent fatal error

Occurred on search page, but potentially others too
This commit is contained in:
Keegan Rankin 2024-02-16 13:03:13 -08:00
parent e18bfc02d0
commit 7c654e2dd5

View file

@ -16,7 +16,7 @@ function geofresco_preprocess_page_title(&$variables) {
return; return;
} }
$string = isset($variables['title']['#markup']) ? $variables['title']['#markup'] : FALSE; $string = isset($variables['title']['#markup']) ? $variables['title']['#markup'] : FALSE;
if ($string && $pos = strpos($string, "'s blog", -7)) { if ($string && strlen($string) > 7 && $pos = strpos($string, "'s blog", -7)) {
$uid = substr($string, 0, $pos); $uid = substr($string, 0, $pos);
if (is_numeric($uid) && $account = \Drupal\user\Entity\User::load($uid)) { if (is_numeric($uid) && $account = \Drupal\user\Entity\User::load($uid)) {
$variables['title'] = [ $variables['title'] = [