wp_get_current_user is overridden
-
Hello,
We have an issue when calling
wp_get_current_user()
.This is the issue we’ve seen:
[17-Oct-2023 18:24:22 UTC] PHP Warning: Attempt to read property "roles" on int in /home/japaneseknives/public_html/wp-content/plugins/wordpress-seo/admin/capabilities/class-register-capabilities.php on line 100 [17-Oct-2023 18:24:22 UTC] PHP Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in /home/japaneseknives/public_html/wp-content/plugins/wordpress-seo/admin/capabilities/class-register-capabilities.php:100 Stack trace: #0 /home/japaneseknives/public_html/wp-content/plugins/wordpress-seo/admin/capabilities/class-register-capabilities.php(100): in_array('wpseo_manager', NULL, true) #1 /home/japaneseknives/public_html/wp-includes/class-wp-hook.php(312): WPSEO_Register_Capabilities->map_meta_cap_for_seo_manager(Array, 'manage_options') #2 /home/japaneseknives/public_html/wp-includes/plugin.php(205): WP_Hook->apply_filters(Array, Array) #3 /home/japaneseknives/public_html/wp-includes/capabilities.php(842): apply_filters('map_meta_cap', Array, 'manage_options', 0, Array) #4 /home/japaneseknives/public_html/wp-includes/class-wp-user.php(777): map_meta_cap('manage_options', 0) #5 /home/japaneseknives/public_html/wp-includes/capabilities.php(985): WP_User->has_cap('manage_options') #6 /home/japaneseknives/public_html/wp-includes/capabilities.php(877): user_can(Object(WP_User), 'manage_options') #7 /home/japaneseknives/public_html/wp-content/plugins/perfmatters/inc/script_manager.php(3): current_user_can('manage_options') #8 /home/japaneseknives/public_html/wp-content/plugins/perfmatters/inc/functions_script_manager.php(23): include('/home/japanesek...') #9 /home/japaneseknives/public_html/wp-includes/class-wp-hook.php(310): perfmatters_script_manager('') #10 /home/japaneseknives/public_html/wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters('', Array) #11 /home/japaneseknives/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #12 /home/japaneseknives/public_html/wp-includes/load.php(1252): do_action('shutdown') #13 [internal function]: shutdown_action_hook() #14 {main} thrown in /home/japaneseknives/public_html/wp-content/plugins/wordpress-seo/admin/capabilities/class-register-capabilities.php on line 100
Naturally we’ve contacted YoastSEO and asked for their help. They have identified that the source of the issue lies with your plugin.
Here is what Yoast said:
We have brought this issue to the attention of our developers, who have identified the problem in the code of the Plugin Load Filter. The respective plugin authors will need to fix this issue. Specifically, Line 73 should be modified to something likereturn WP_User( 0 );
. The Plugin Load Filter is currently overridingwp_get_current_user
, which is acceptable, but it fails to maintain the expected return type of beWP_User
. It should always return WP_User, not an integerint
.Can you please help resolve this issue?
Thank you
- The topic ‘wp_get_current_user is overridden’ is closed to new replies.