mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 15:50:09 +00:00
Media: Use consistent method for instantiating an attachment author object in Media Library.
Previously, attachments without an author could cause a PHP fatal error due to calling the `::exists()` method on a `false` value. Props antpb, carloscastilloadhoc, hellofromTonya, garrett-eclipse. Fixes #52030. git-svn-id: https://develop.svn.wordpress.org/trunk@49979 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -3929,6 +3929,7 @@ function wp_prepare_attachment_for_js( $attachment ) {
|
||||
);
|
||||
|
||||
$author = new WP_User( $attachment->post_author );
|
||||
|
||||
if ( $author->exists() ) {
|
||||
$author_name = $author->display_name ? $author->display_name : $author->nickname;
|
||||
$response['authorName'] = html_entity_decode( $author_name, ENT_QUOTES, get_bloginfo( 'charset' ) );
|
||||
|
||||
Reference in New Issue
Block a user