Issue #3241265 by alexpott: user_user_view() triggers a deprecation in PHP 8.1

merge-requests/1227/head
Lee Rowlands 2021-10-08 15:22:38 +10:00
parent 9c2be57019
commit deb93f5ff2
No known key found for this signature in database
GPG Key ID: 2B829A3DF9204DC4
1 changed files with 1 additions and 1 deletions

View File

@ -299,7 +299,7 @@ function user_is_blocked($name) {
* Implements hook_ENTITY_TYPE_view() for user entities.
*/
function user_user_view(array &$build, UserInterface $account, EntityViewDisplayInterface $display) {
if ($display->getComponent('member_for')) {
if ($account->isAuthenticated() && $display->getComponent('member_for')) {
$build['member_for'] = [
'#type' => 'item',
'#markup' => '<h4 class="label">' . t('Member for') . '</h4> ' . \Drupal::service('date.formatter')->formatTimeDiffSince($account->getCreatedTime()),