[wp-trac] [WordPress Trac] #44972: wp_get_current_user() misbehavior

WordPress Trac noreply at wordpress.org
Sun Sep 23 14:36:08 UTC 2018


#44972: wp_get_current_user() misbehavior
--------------------------+------------------------------
 Reporter:  tazotodua     |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by tazotodua):

 with further check, i've finally reproduce it simpler:

 in clean WP installation,enter admin dashbord, then just use this code in
 plugin or fuctions.php

 {{{
 require_once(ABSPATH . 'wp-includes/pluggable.php');
 get_user_locale() ; // or directly wp_get_current_user();
 }}}



 refresh dashboard page. you will see the error:

 {{{"Sorry, you are not allowed to access this page."}}}


 (with WP_DEBUG there shows also:  Warning: Use of undefined constant
 AUTH_COOKIE - assumed 'AUTH_COOKIE' (this will throw an Error in a future
 version of PHP) in
 D:\SAQME\__CODES\_________install\wamp\installed\www\wp\3\wp-
 includes\pluggable.php on line 769  )


 so, i think, many plugins are calling `get_user_locate`,
 `get_bloginfo('language')`,  `load_default_textdomain` (or many many other
 functions, that call `wp_get_current_user` finally), thus, also, many
 other plugins seems to use:

 require_once(ABSPATH . 'wp-includes/pluggable.php');

 in their constructors (or directly in plain-code if not CLASS).

 so, that breaks admin dashboards.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44972#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list