Skip to content

Commit

Permalink
Return immediately if comment is null in avatar block (#40835)
Browse files Browse the repository at this point in the history
  • Loading branch information
michalczaplinski committed May 5, 2022
1 parent 1b3a899 commit e984e85
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/block-library/src/avatar/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ function render_block_core_avatar( $attributes, $content, $block ) {
return sprintf( '<div %1s>%2s</div>', $wrapper_attributes, $avatar_block );
}
$comment = get_comment( $block->context['commentId'] );
/* translators: %s is the Comment Author name */
$alt = sprintf( __( '%s Avatar' ), $comment->comment_author );
if ( ! $comment ) {
return '';
}
/* translators: %s is the Comment Author name */
$alt = sprintf( __( '%s Avatar' ), $comment->comment_author );
$avatar_block = get_avatar(
$comment,
$size,
Expand Down

0 comments on commit e984e85

Please sign in to comment.