[wp-trac] [WordPress Trac] #62959: Ensure wp_roles() returns an instance of WP_Roles
WordPress Trac
noreply at wordpress.org
Thu Feb 13 17:41:55 UTC 2025
#62959: Ensure wp_roles() returns an instance of WP_Roles
-----------------------------+-----------------------------
Reporter: marian1 | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Role/Capability | Version:
Severity: minor | Keywords:
Focuses: |
-----------------------------+-----------------------------
Currently, `wp_roles()` only checks whether the global variable
`$wp_roles` is set before returning it. As global variables can be
overridden, it should verify that `$wp_roles` is indeed a `WP_Roles`
object to ensure that `wp_roles()` consistently returns a `WP_Roles`
instance.
Refer to `wp_scripts()` and `wp_styles()` for the correct approach.
See #62562 for another example where the type of a global variable is not
properly checked.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62959>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list