Skip to content

Commit

Permalink
class-register-capabilities.php in_array() TypeError fix
Browse files Browse the repository at this point in the history
$user->roles may be undefined, so passing it into in_array() produces a TypeError. Found this to completely block loading of the WP admin. Simple fix of adding a fallback value.
  • Loading branch information
kfeinUI authored Nov 30, 2024
1 parent af60b42 commit 2b5b4a6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion admin/capabilities/class-register-capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function map_meta_cap_for_seo_manager( $caps, $cap ) {
}

// User must be of role wpseo_manager.
if ( ! in_array( 'wpseo_manager', $user->roles, true ) ) {
if ( ! in_array( 'wpseo_manager', $user->roles ?? [], true ) ) {

Check failure on line 100 in admin/capabilities/class-register-capabilities.php

View workflow job for this annotation

GitHub Actions / Check code style

Operation must be bracketed
return $caps;
}

Expand Down

0 comments on commit 2b5b4a6

Please sign in to comment.