Skip to content

Commit

Permalink
Fix: Fatal php error if a template was created by an author that was …
Browse files Browse the repository at this point in the history
…deleted. (#56990)
  • Loading branch information
jorgefilipecosta authored Dec 12, 2023
1 parent 5b688d4 commit 482ac0c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/compat/wordpress-6.5/rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ function _gutenberg_get_wp_templates_author_text_field( $template_object ) {
case 'site':
return get_bloginfo( 'name' );
case 'user':
return get_user_by( 'id', $template_object['author'] )->get( 'display_name' );
$author = get_user_by( 'id', $template_object['author'] );
if ( ! $author ) {
return __( 'Unknown author', 'gutenberg' );
}
return $author->get( 'display_name' );
}
}

Expand Down

1 comment on commit 482ac0c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 482ac0c.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7186197134
📝 Reported issues:

Please sign in to comment.