[wp-trac] [WordPress Trac] #61161: current_user_can fatal error

WordPress Trac noreply at wordpress.org
Tue May 7 10:37:28 UTC 2024


#61161: current_user_can fatal error
-----------------------------+-----------------------------
 Reporter:  kkmuffme         |      Owner:  (none)
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Role/Capability  |    Version:  trunk
 Severity:  major            |   Keywords:
  Focuses:                   |
-----------------------------+-----------------------------
 `current_user_can` uses
 https://developer.wordpress.org/reference/functions/wp_get_current_user/
 internally, however this function is only loaded only much after
 `current_user_can` is declared. This means using `current_user_can` on
 e.g. `mu_plugins_loaded` or `plugin_loaded` hook will result in a fatal
 error.

 Changing the `wp_get_current_user()` call in there to
 `_wp_get_current_user()` fixes that issue, but then it fails on
 `wp_set_current_user()` which is pluggable too.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61161>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list