Issue #3278883 by vhin0210, longwave: TypeError: Argument 1 passed to Drupal\Core\Entity\EntityViewBuilder::view() must implement interface Drupal\Core\Entity\EntityInterface, null given, called in core/modules/node/node.module on line 559

(cherry picked from commit dd66424535)
merge-requests/4100/merge
catch 2023-05-23 11:51:31 +01:00
parent abd5bde63f
commit cb055605a6
1 changed files with 5 additions and 3 deletions

View File

@ -553,9 +553,11 @@ function template_preprocess_node(&$variables) {
// 'compact' view mode on the User entity. Note that the 'compact'
// view mode might not be configured, so remember to always check the
// theme setting first.
$variables['author_picture'] = \Drupal::entityTypeManager()
->getViewBuilder('user')
->view($node->getOwner(), 'compact');
if ($node_owner = $node->getOwner()) {
$variables['author_picture'] = \Drupal::entityTypeManager()
->getViewBuilder('user')
->view($node_owner, 'compact');
}
}
}
}