-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed
Labels
[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended
Description
https://github.com/WordPress/gutenberg/blob/v2.4.0/lib/register.php#L433 is written with the assumption that those role names exist in the system. This is not always the case, because roles can be deleted or renamed for multiple valid reasons.
As it stands, Gutenberg currently crashes my WP, because my user has two roles administrator and editor. For some reason get_role( "editor" ) evaluates to null, thereby has no has_cap() method.
$role_name string (13) "administrator"
→$role WP_Role (2)
→ Called from <ROOT>/wp-content/plugins/gutenberg/lib/register.php:435 [gutenberg_register_post_types()]
$role_name string (6) "editor"
$role null
→ Called from <ROOT>/wp-content/plugins/gutenberg/lib/register.php:435 [gutenberg_register_post_types()]
[14-Mar-2018 18:28:11 UTC] PHP Fatal error: Uncaught Error: Call to a member function has_cap() on null in /home/warmpress/wp-content/plugins/gutenberg/lib/register.php:436
My takeaway here is that we should check get_role() result for validity before proceeding.
MarcusWernicke, shaunsantacruz and lkraav
Metadata
Metadata
Assignees
Labels
[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended