Skip to content

Commit 7c610a1

Browse files
authored
Merge branch 'WordPress:trunk' into trunk
2 parents bc9d98c + 7be47cf commit 7c610a1

File tree

4 files changed

+59
-19
lines changed

4 files changed

+59
-19
lines changed

src/wp-admin/includes/ajax-actions.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -690,18 +690,21 @@ function _wp_ajax_add_hierarchical_term() {
690690
);
691691
}
692692

693+
$parent_dropdown_args = array(
694+
'taxonomy' => $taxonomy->name,
695+
'hide_empty' => 0,
696+
'name' => 'new' . $taxonomy->name . '_parent',
697+
'orderby' => 'name',
698+
'hierarchical' => 1,
699+
'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —',
700+
);
701+
702+
/** This filter is documented in wp-admin/includes/meta-boxes.php */
703+
$parent_dropdown_args = apply_filters( 'post_edit_category_parent_dropdown_args', $parent_dropdown_args );
704+
693705
ob_start();
694706

695-
wp_dropdown_categories(
696-
array(
697-
'taxonomy' => $taxonomy->name,
698-
'hide_empty' => 0,
699-
'name' => 'new' . $taxonomy->name . '_parent',
700-
'orderby' => 'name',
701-
'hierarchical' => 1,
702-
'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —',
703-
)
704-
);
707+
wp_dropdown_categories( $parent_dropdown_args );
705708

706709
$sup = ob_get_clean();
707710

src/wp-includes/capabilities.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ function map_meta_cap( $cap, $user_id, ...$args ) {
6060
break;
6161
case 'edit_user':
6262
case 'edit_users':
63+
// Non-existent users can't edit users, not even themselves.
64+
if ( $user_id < 1 ) {
65+
$caps[] = 'do_not_allow';
66+
break;
67+
}
68+
6369
// Allow user to edit themselves.
6470
if ( 'edit_user' === $cap && isset( $args[0] ) && $user_id === (int) $args[0] ) {
6571
break;

src/wp-includes/update.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
*
2222
* @since 2.3.0
2323
*
24-
* @global string $wp_version Used to check against the newest WordPress version.
2524
* @global wpdb $wpdb WordPress database abstraction object.
2625
* @global string $wp_local_package Locale code of the package.
2726
*
@@ -317,8 +316,6 @@ function wp_version_check( $extra_stats = array(), $force_check = false ) {
317316
*
318317
* @since 2.3.0
319318
*
320-
* @global string $wp_version The WordPress version string.
321-
*
322319
* @param array $extra_stats Extra statistics to report to the WordPress.org API.
323320
*/
324321
function wp_update_plugins( $extra_stats = array() ) {
@@ -590,8 +587,6 @@ function wp_update_plugins( $extra_stats = array() ) {
590587
*
591588
* @since 2.7.0
592589
*
593-
* @global string $wp_version The WordPress version string.
594-
*
595590
* @param array $extra_stats Extra statistics to report to the WordPress.org API.
596591
*/
597592
function wp_update_themes( $extra_stats = array() ) {

tests/phpunit/tests/user/capabilities.php

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,13 +1830,49 @@ public function test_multisite_administrator_can_not_edit_users() {
18301830
$this->assertFalse( current_user_can( 'edit_user', $other_user->ID ) );
18311831
}
18321832

1833-
public function test_user_can_edit_self() {
1834-
foreach ( self::$users as $role => $user ) {
1835-
wp_set_current_user( $user->ID );
1836-
$this->assertTrue( current_user_can( 'edit_user', $user->ID ), "User with role {$role} should have the capability to edit their own profile" );
1833+
/**
1834+
* Test if a user can edit their own profile based on their role.
1835+
*
1836+
* @ticket 63684
1837+
*
1838+
* @dataProvider data_user_can_edit_self
1839+
*
1840+
* @param string $role The role of the user.
1841+
* @param bool $can_edit_self Whether the user can edit their own profile.
1842+
*/
1843+
public function test_user_can_edit_self( $role, $can_edit_self = true ) {
1844+
$user = self::$users[ $role ];
1845+
wp_set_current_user( $user->ID );
1846+
1847+
if ( $can_edit_self ) {
1848+
$this->assertTrue(
1849+
current_user_can( 'edit_user', $user->ID ),
1850+
"User with role '{$role}' should have the capability to edit their own profile"
1851+
);
1852+
} else {
1853+
$this->assertFalse(
1854+
current_user_can( 'edit_user', $user->ID ),
1855+
"User with role '{$role}' should not have the capability to edit their own profile"
1856+
);
18371857
}
18381858
}
18391859

1860+
/**
1861+
* Data provider for test_user_can_edit_self.
1862+
*
1863+
* @return array[] Data provider.
1864+
*/
1865+
public static function data_user_can_edit_self() {
1866+
return array(
1867+
'anonymous' => array( 'anonymous', false ),
1868+
'administrator' => array( 'administrator', true ),
1869+
'editor' => array( 'editor', true ),
1870+
'author' => array( 'author', true ),
1871+
'contributor' => array( 'contributor', true ),
1872+
'subscriber' => array( 'subscriber', true ),
1873+
);
1874+
}
1875+
18401876
public function test_only_admins_and_super_admins_can_remove_users() {
18411877
if ( is_multisite() ) {
18421878
$this->assertTrue( user_can( self::$super_admin->ID, 'remove_user', self::$users['subscriber']->ID ) );

0 commit comments

Comments
 (0)