[wp-trac] [WordPress Trac] #39205: Replace is_super_admin() check with current_user_can( 'upgrade_database' )

WordPress Trac noreply at wordpress.org
Sun Dec 11 23:29:14 UTC 2016


#39205: Replace is_super_admin() check with current_user_can( 'upgrade_database' )
-------------------------------------------------+-------------------------
 Reporter:  dhanendran                           |       Owner:  flixos90
     Type:  enhancement                          |      Status:  assigned
 Priority:  normal                               |   Milestone:  4.8
Component:  Role/Capability                      |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch needs-dev-note needs-      |     Focuses:  multisite
  unit-tests                                     |
-------------------------------------------------+-------------------------

Comment (by flixos90):

 @johnjamesjacoby: I like the idea of having this capability check before
 upgrade routines. I think we should only check for this when upgrades
 happen via the UI though as I'm not quite sure about the consequences if
 we put such a check into functions like `wp_upgrade()` directly (for
 example, how does WP-CLI handle this?).

 My approach would be to put `current_user_can( 'upgrade_database' )` into
 `wp-admin/network/upgrade.php`, it could replace the existing
 `manage_network` check in order to be more precise. We might also be able
 to insert the same check into `wp-admin/upgrade.php` - the latter would
 depend on our `map_meta_cap()` approach for the function though: Currently
 everyone can access the `wp-admin/upgrade.php` screen and perform a
 database upgrade as far as I can see. We can either change that (probably
 not though), or we could say that on a non-multisite setup the capability
 maps to `exist` which everyone has. It could look like this (in
 `map_meta_cap()`):

 {{{
 case 'upgrade_database':
     if ( is_multisite() ) {
         $caps[] = 'manage_network';
     } else {
         $caps[] = 'exist';
     }
 }}}

 The only thing that would technically change is that in a multisite setup
 only the network administrator could access the `wp-admin/upgrade.php`
 page while currently everyone can. I don't really think the current
 (pretty much open) implementation makes sense, but I might be missing
 something.

 Anyways, if we do anything with that capability beyond the existing patch
 (and unit tests), we should handle this in a separate ticket.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39205#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list