Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#39065 closed enhancement (fixed)

Replace `is_super_admin()` checks with `manage_network` cap checks for `get_dashboard_url()`

Reported by: flixos90's profile flixos90 Owned by: flixos90's profile flixos90
Milestone: 4.8 Priority: normal
Severity: normal Version:
Component: Role/Capability Keywords: has-patch has-unit-tests commit
Focuses: multisite Cc:


This is part of the #37616 task. The two is_super_admin() checks in get_dashboard_url() should be replaced by user_can( $user_id, 'manage_network' ) which is a suitable cap here. In addition to the mentioned ticket's goals, this fixes a possible bug since one of the two checks does not actually pass the $user_id to is_super_admin() which would always check for the current user instead of the ID passed to the function.

Since there are no unit tests for get_dashboard_url(), these should be added as well.

Attachments (3)

link-template.diff (959 bytes) - added by iaaxpage 7 years ago.
Replaced is_super_admin with user_can($user_id, 'manage_network' )
39065.diff (3.1 KB) - added by flixos90 7 years ago.
39065.2.diff (3.5 KB) - added by flixos90 7 years ago.

Download all attachments as: .zip

Change History (9)

7 years ago

Replaced is_super_admin with user_can($user_id, 'manage_network' )

#1 @iaaxpage
7 years ago

  • Keywords has-patch added

7 years ago

#2 @flixos90
7 years ago

  • Keywords has-unit-tests added
  • Owner set to flixos90
  • Status changed from new to assigned

Thanks again for the patch @iaaxpage!

I added unit tests in 39065.diff.

7 years ago

#3 @flixos90
7 years ago

39065.2.diff improves the unit tests as the common test user is now created in wpSetUpBeforeClass() to speed up the related tests.

#4 @jeremyfelt
7 years ago

  • Keywords commit added

+1 39065.2.diff looks good, @flixos90.

We already discussed this off-ticket a bit, but we can remove the $wp_rewrite->init(); portion as it isn't necessary here.

#5 @flixos90
7 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 39589:

Multisite: Replace is_super_admin() with manage_network in get_dashboard_url().

Unit tests for get_dashboard_url() have been added.

Props iaaxpage.
Fixes #39065. See #37616.

#6 @flixos90
7 years ago

In 39590:

Tests: Use wp_delete_user() during teardown to delete a single site's user.

Fixes failing tests for get_dashboard_url().

Fixes #39065.

Note: See TracTickets for help on using tickets.