Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.4.0: gutenberg_register_post_types() #5617

Closed
lkraav opened this issue Mar 14, 2018 · 1 comment
Closed

2.4.0: gutenberg_register_post_types() #5617

lkraav opened this issue Mar 14, 2018 · 1 comment
Labels
[Type] Bug An existing feature does not function as intended

Comments

@lkraav
Copy link

lkraav commented Mar 14, 2018

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.

@lkraav
Copy link
Author

lkraav commented Mar 21, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

2 participants