Skip to content

Simplify get_role() method in WP_Roles class #8637

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/wp-includes/class-wp-roles.php
Original file line number Diff line number Diff line change
@@ -246,11 +246,7 @@ public function remove_cap( $role, $cap ) {
* @return WP_Role|null WP_Role object if found, null if the role does not exist.
*/
public function get_role( $role ) {
if ( isset( $this->role_objects[ $role ] ) ) {
return $this->role_objects[ $role ];
} else {
return null;
}
return $this->role_objects[ $role ] ?? null;
}

/**

Unchanged files with check annotations Beta

await expect(
page,
'should redirect to the installation page'
).toHaveURL( /wp-admin\/install\.php$/ );

Check failure on line 40 in tests/e2e/specs/install.test.js

GitHub Actions / Test with SCRIPT_DEBUG enabled / Run E2E tests

[chromium] › tests/e2e/specs/install.test.js:34:6 › WordPress installation process › should install WordPress with pre-existing database credentials

1) [chromium] › tests/e2e/specs/install.test.js:34:6 › WordPress installation process › should install WordPress with pre-existing database credentials Error: should redirect to the installation page Timed out 5000ms waiting for expect(locator).toHaveURL(expected) Locator: locator(':root') Expected pattern: /wp-admin\/install\.php$/ Received string: "http://localhost:8889/" Call log: - should redirect to the installation page with timeout 5000ms - waiting for locator(':root') 9 × locator resolved to <html lang="en-US">…</html> - unexpected value "http://localhost:8889/" 38 | page, 39 | 'should redirect to the installation page' > 40 | ).toHaveURL( /wp-admin\/install\.php$/ ); | ^ 41 | 42 | await expect( 43 | page.getByText( /WordPress database error/ ), at /home/runner/work/wordpress-develop/wordpress-develop/tests/e2e/specs/install.test.js:40:5
await expect(
page.getByText( /WordPress database error/ ),
test( 'Test dismissing failed upload works correctly', async ({ page, admin, requestUtils }) => {
// Log in before visiting admin page.
await requestUtils.login();
await admin.visitAdminPage( '/media-new.php' );

Check failure on line 14 in tests/e2e/specs/media-upload.test.js

GitHub Actions / Test with SCRIPT_DEBUG enabled / Run E2E tests

[chromium] › tests/e2e/specs/media-upload.test.js:11:5 › Test dismissing failed upload works correctly

2) [chromium] › tests/e2e/specs/media-upload.test.js:11:5 › Test dismissing failed upload works correctly Error: Not logged in 12 | // Log in before visiting admin page. 13 | await requestUtils.login(); > 14 | await admin.visitAdminPage( '/media-new.php' ); | ^ 15 | 16 | // It takes a moment for the multi-file uploader to become available. 17 | await page.waitForLoadState('load'); at Admin.visitAdminPage (/home/runner/work/wordpress-develop/wordpress-develop/node_modules/@wordpress/e2e-test-utils-playwright/src/admin/visit-admin-page.ts:36:9) at /home/runner/work/wordpress-develop/wordpress-develop/tests/e2e/specs/media-upload.test.js:14:2
// It takes a moment for the multi-file uploader to become available.
await page.waitForLoadState('load');