Make WordPress Core

Changeset 21152


Ignore:
Timestamp:
06/27/2012 07:27:54 PM (14 years ago)
Author:
nacin
Message:

Remove 'fall through' points in map_meta_cap() as they can hide bugs.

File:
1 edited

Legend:

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

    r21060 r21152  
    948948                break;
    949949        case 'edit_user':
     950        case 'edit_users':
    950951                // Allow user to edit itself
    951                 if ( isset( $args[0] ) && $user_id == $args[0] )
     952                if ( 'edit_user' == $cap && isset( $args[0] ) && $user_id == $args[0] )
    952953                        break;
    953                 // Fall through
    954         case 'edit_users':
     954
    955955                // If multisite these caps are allowed only for super admins.
    956956                if ( is_multisite() && !is_super_admin( $user_id ) )
    957957                        $caps[] = 'do_not_allow';
    958958                else
    959                         $caps[] = 'edit_users'; // Explicit due to primitive fall through
     959                        $caps[] = 'edit_users'; // edit_user maps to edit_users.
    960960                break;
    961961        case 'delete_post':
     
    11311131                if ( defined( 'DISALLOW_UNFILTERED_HTML' ) && DISALLOW_UNFILTERED_HTML )
    11321132                        $caps[] = 'do_not_allow';
     1133                elseif ( is_multisite() && ! is_super_admin( $user_id ) )
     1134                        $caps[] = 'do_not_allow';
    11331135                else
    11341136                        $caps[] = $cap;
     
    11371139        case 'edit_plugins':
    11381140        case 'edit_themes':
    1139                 if ( defined('DISALLOW_FILE_EDIT') && DISALLOW_FILE_EDIT ) {
     1141                // Disallow the file editors.
     1142                if ( defined( 'DISALLOW_FILE_EDIT' ) && DISALLOW_FILE_EDIT )
    11401143                        $caps[] = 'do_not_allow';
    1141                         break;
    1142                 }
    1143                 // Fall through if not DISALLOW_FILE_EDIT.
     1144                elseif ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS )
     1145                        $caps[] = 'do_not_allow';
     1146                elseif ( is_multisite() && ! is_super_admin( $user_id ) )
     1147                        $caps[] = 'do_not_allow';
     1148                else
     1149                        $caps[] = $cap;
     1150                break;
    11441151        case 'update_plugins':
    11451152        case 'delete_plugins':
     
    11491156        case 'install_themes':
    11501157        case 'update_core':
    1151                 // Disallow anything that creates, deletes, or edits core, plugin, or theme files.
     1158                // Disallow anything that creates, deletes, or updates core, plugin, or theme files.
    11521159                // Files in uploads are excepted.
    1153                 if ( defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS ) {
     1160                if ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS )
    11541161                        $caps[] = 'do_not_allow';
    1155                         break;
    1156                 }
    1157                 // Fall through if not DISALLOW_FILE_MODS.
     1162                elseif ( is_multisite() && ! is_super_admin( $user_id ) )
     1163                        $caps[] = 'do_not_allow';
     1164                else
     1165                        $caps[] = $cap;
     1166                break;
    11581167        case 'delete_user':
    11591168        case 'delete_users':
    1160                 // If multisite these caps are allowed only for super admins.
    1161                 if ( is_multisite() && !is_super_admin( $user_id ) ) {
     1169                // If multisite only super admins can delete users.
     1170                if ( is_multisite() && ! is_super_admin( $user_id ) )
    11621171                        $caps[] = 'do_not_allow';
    1163                 } else {
    1164                         if ( 'delete_user' == $cap )
    1165                                 $cap = 'delete_users';
    1166                         $caps[] = $cap;
    1167                 }
     1172                else
     1173                        $caps[] = 'delete_users'; // delete_user maps to delete_users.
    11681174                break;
    11691175        case 'create_users':
Note: See TracChangeset for help on using the changeset viewer.