Make WordPress Core

Changeset 33967


Ignore:
Timestamp:
09/09/2015 03:41:27 AM (9 years ago)
Author:
wonderboymusic
Message:

Ensure that role is not empty before adding it in add_role() function and methods.

Props MikeHansenMe, dannydehaan, michielhab.
Fixes #23746.

Location:
trunk/src/wp-includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/capabilities-functions.php

    r33752 r33967  
    472472 */
    473473function add_role( $role, $display_name, $capabilities = array() ) {
     474    if ( empty( $role ) ) {
     475        return;
     476    }
    474477    return wp_roles()->add_role( $role, $display_name, $capabilities );
    475478}
  • trunk/src/wp-includes/class-wp-roles.php

    r33752 r33967  
    173173     */
    174174    public function add_role( $role, $display_name, $capabilities = array() ) {
    175         if ( isset( $this->roles[$role] ) )
    176             return;
     175        if ( empty( $role ) || isset( $this->roles[ $role ] ) ) {
     176            return;
     177        }
    177178
    178179        $this->roles[$role] = array(
  • trunk/src/wp-includes/class-wp-user.php

    r33958 r33967  
    440440     */
    441441    public function add_role( $role ) {
     442        if ( empty( $role ) ) {
     443            return;
     444        }
     445
    442446        $this->caps[$role] = true;
    443447        update_user_meta( $this->ID, $this->cap_key, $this->caps );
Note: See TracChangeset for help on using the changeset viewer.