WordPress.org

Make WordPress Core

Changeset 49979 for trunk


Ignore:
Timestamp:
01/18/2021 12:53:30 PM (9 months ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/media.php

    r49927 r49979  
    32893289    $att_url = wp_get_attachment_url( $attachment_id );
    32903290
    3291     $author = get_userdata( $post->post_author );
     3291    $author = new WP_User( $post->post_author );
    32923292
    32933293    $uploaded_by_name = __( '(no author)' );
    32943294    $uploaded_by_link = '';
     3295
    32953296    if ( $author->exists() ) {
    32963297        $uploaded_by_name = $author->display_name ? $author->display_name : $author->nickname;
  • trunk/src/wp-includes/media.php

    r49936 r49979  
    39303930
    39313931    $author = new WP_User( $attachment->post_author );
     3932
    39323933    if ( $author->exists() ) {
    39333934        $author_name            = $author->display_name ? $author->display_name : $author->nickname;
Note: See TracChangeset for help on using the changeset viewer.