Issue #3240915 by andypost, alexpott: Passing NULL to \Drupal\Component\Utility\Unicode::truncate() causes deprecations on PHP 8.1

merge-requests/1009/merge
catch 2021-10-11 19:57:46 +01:00
parent adf864ee84
commit caf0971080
2 changed files with 5 additions and 2 deletions

View File

@ -63,7 +63,7 @@ class LinkSeparateFormatter extends LinkFormatter {
}
$url_title = $url->toString();
if (!empty($settings['trim_length'])) {
$link_title = Unicode::truncate($link_title, $settings['trim_length'], FALSE, TRUE);
$link_title = $link_title !== NULL ? Unicode::truncate($link_title, $settings['trim_length'], FALSE, TRUE) : NULL;
$url_title = Unicode::truncate($url_title, $settings['trim_length'], FALSE, TRUE);
}

View File

@ -111,7 +111,10 @@ class MenuLink extends DrupalSqlBase {
}
$row->setSourceProperty('options', unserialize($row->getSourceProperty('options')));
$row->setSourceProperty('enabled', !$row->getSourceProperty('hidden'));
$row->setSourceProperty('description', Unicode::truncate($row->getSourceProperty('options/attributes/title'), 255));
$description = $row->getSourceProperty('options/attributes/title');
if ($description !== NULL) {
$row->setSourceProperty('description', Unicode::truncate($description, 255));
}
return parent::prepareRow($row);
}