Making WordPress.org


Ignore:
Timestamp:
09/29/2020 02:16:23 AM (6 years ago)
Author:
dd32
Message:

Theme Directory: API: Better handling for invalid or missing user field when requesting user favorites.

Fixes a PHP Notice when it's unset and unexpected results when it's invalid.

File:
1 edited

Legend:

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

    r10294 r10296  
    9999                        'author',
    100100                        'browse',
     101                        'user',
    101102                        'locale',
    102103                        'per_page',
    … …  
    111112                                $this->bad_input = true;
    112113                        }
     114                }
     115
     116                // Favorites requests require a user to fetch favorites for.
     117                if ( isset( $this->request->browse ) && 'favorites' === $this->request->browse && ! isset( $this->request->user ) ) {
     118                        $this->request->user = '';
     119                        $this->bad_input = true;
    113120                }
    114121
    … …  
    547554                                $this->cache_life = HOUR_IN_SECONDS;
    548555                        } elseif ( 'favorites' == $this->request->browse ) {
    549                                 $this->query['favorites_user'] = (string) $this->request->user;
     556                                $this->query['favorites_user'] = $this->request->user;
    550557                        }
    551558
Note: See TracChangeset for help on using the changeset viewer.