[wp-trac] [WordPress Trac] #59000: Add a check for wp_get_current_user to current_user_can
WordPress Trac
noreply at wordpress.org
Tue Aug 8 09:51:15 UTC 2023
#59000: Add a check for wp_get_current_user to current_user_can
--------------------------+-----------------------------
Reporter: scruffian | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
This issue was raised in
https://github.com/WordPress/gutenberg/issues/53284, but I think its
exposing an issue with WordPress more generally.
It's possible to call `current_user_can` before `wp_get_current_user` has
been defined, but we don't have any checks for `wp_get_current_user`
inside `current_user_can`. I think we should check whether the function
exists before we attempt to call it to avoid fatal errors that are
possible as shown by https://github.com/WordPress/gutenberg/issues/53284.
I have a potential fix here: https://github.com/WordPress/wordpress-
develop/pull/4959, but I'm open to other suggestions.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59000>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list