WordPress.org

Making WordPress.org

Changeset 10384


Ignore:
Timestamp:
10/16/2020 05:06:16 AM (15 months ago)
Author:
dd32
Message:

Plugin Directory: When querying author archives, don't assume the user exists, guards against junk requests causing notices.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php

    r10352 r10384  
    845845        // Author Archives need to be created
    846846        if ( $wp_query->is_main_query() && $wp_query->is_author() ) {
    847             $user = isset( $wp_query->query['author_name'] ) ? $wp_query->query['author_name'] : get_user_by( 'id', $wp_query->query['author'] )->user_nicename;
    848 
    849             $viewing_own_author_archive = is_user_logged_in() && ( current_user_can( 'plugin_review' ) || 0 === strcasecmp( $user, wp_get_current_user()->user_nicename ) );
     847            $user = false;
     848            if ( isset( $wp_query->query['author_name'] ) ) {
     849                $user = $wp_query->query['author_name'];
     850            } elseif ( ! empty( $wp_query->query['author'] ) ) {
     851                $user = get_user_by( 'id', $wp_query->query['author'] );
     852                if ( $user ) {
     853                    $user = $user->user_nicename;
     854                }
     855            }
     856
     857            $viewing_own_author_archive = is_user_logged_in() && $user && ( current_user_can( 'plugin_review' ) || 0 === strcasecmp( $user, wp_get_current_user()->user_nicename ) );
    850858
    851859            // Author archives by default list plugins you're a contributor on.
Note: See TracChangeset for help on using the changeset viewer.