Fatal error from does_user_have_multisite_capability function
-
Hello,
We’re getting a fatal error caused by the capability check in the
does_user_have_multisite_capability
function.We’re running a multi-multi-network setup, and super-admin users are unable to load the user list due to a critical error (https://smile.d.pr/i/13xXYk). Admins are able to view the user list because the 2FA status column is not available to them so doesn’t appear to trigger the error.
In the error logs, we’ve gotten the following: “PHP message: PHP Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, bool given in /www/oursite/public/wp-content/plugins/wordfence/modules/login-security/classes/controller/permissions.php:443
Stack trace:
- #0 /www/oursite/public/wp-content/plugins/wordfence/modules/login-security/classes/controller/permissions.php(443): array_key_exists(‘wf2fa_activate_…’, false)
- #1 /www/oursite/public/wp-content/plugins/wordfence/modules/login-security/classes/controller/users.php(195): WordfenceLS\Controller_Permissions->does_user_have_multisite_capability(Object(WP_User), ‘wf2fa_activate_…’)
- #2 /www/oursite/public/wp-content/plugins/wordfence/modules/login-security/classes/controller/users.php(651): WordfenceLS\Controller_Users->can_activate_2fa(Object(WP_User))
- #3 /www/oursite/public/wp-includes/class-wp-hook.php(324): WordfenceLS\Controller_”
We’ve looked at the plugin code referenced in the public fuction
does_user_have_multisite_capability($user, $capability)
. The lineif (array_key_exists($capability, $capabilities) && $capabilities[$capability]) { return true; }
is where our error originates because $capabilities is false so array_key_exists throws an exception. We believe that changing this line toif (is_array($capabilities) && array_key_exists($capability, $capabilities) && $capabilities[$capability]) { return true; }
would resolve the issue we’re seeing.Are you able to help?
Chelsey
- You must be logged in to reply to this topic.