Making WordPress.org


Ignore:
Timestamp:
10/20/2016 04:07:33 AM (10 years ago)
Author:
pento
Message:

Plugin directory: Fix a PHP warning introduced in [4260].

The return value of get_the_terms() needs to be tested to ensure it's an array.

See #2111.

File:
1 edited

Legend:

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

    r4260 r4276  
    6161                                if ( ! $plugin_edit_cap ) {
    6262                                        // Contributors can view, but not edit.
    63                                         $contributors = (array) wp_list_pluck( get_the_terms( $post, 'plugin_contributors' ), 'name' );
    64                                         if ( in_array( $user->user_nicename, $contributors, true ) ) {
    65                                                 $required_caps[] = 'exist'; // All users are allowed to exist, even when they have no role.
    66                                                 break;
     63                                        $terms = get_the_terms( $post, 'plugin_contributors' );
     64                                        if ( is_array( $terms ) ) {
     65                                                $contributors = (array) wp_list_pluck( $terms, 'name' );
     66                                                if ( in_array( $user->user_nicename, $contributors, true ) ) {
     67                                                        $required_caps[] = 'exist'; // All users are allowed to exist, even when they have no role.
     68                                                        break;
     69                                                }
    6770                                        }
    6871                                }
Note: See TracChangeset for help on using the changeset viewer.