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

PostAuthor component can cause a crash for some users #4437

Closed
notnownikki opened this issue Jan 12, 2018 · 8 comments
Closed

PostAuthor component can cause a crash for some users #4437

notnownikki opened this issue Jan 12, 2018 · 8 comments
Assignees
Labels
[Feature] Document Settings Document settings experience [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Milestone

Comments

@notnownikki
Copy link
Member

The PostAuthor component references user.capabilities.level_1, and user.capabilities is sometimes undefined. This causes an immediate crash.

I don't know exactly the circumstances that cause user.capabilities to be undefined, but we had this problem a while back in #2702 and it was fixed for most cases in #4122 .

The check occurs in editor/components/post-author/index.js line 42.

Is there a check we can replace this with, in the same way as we did in #4122?

If someone could give me some insight as to what we should be checking here, I'd quite like to implement the fix so I learn more about this :)

@Kilian
Copy link

Kilian commented Jan 15, 2018

I have this problem still with gutenberg 2.0.0 (Hoped #2702 would fix it, as that is the error I'm getting), not running multisite, single author/admin (me), but has been running + upgraded since WP 2.0. I did a check for a potentially problematic plugins (wp super cache) but disabling that didn't help either.

@notnownikki notnownikki self-assigned this Jan 15, 2018
@notnownikki
Copy link
Member Author

Looking at the change that fixed it for most people, we need to make sure the component gets the new post_capabilities data from the API, and that's been done for most components but not the PostAuthor component.

I think I have enough info to start working on a fix now.

@notnownikki notnownikki added [Type] Bug An existing feature does not function as intended [Status] In Progress Tracking issues with work in progress [Feature] Document Settings Document settings experience labels Jan 15, 2018
@notnownikki
Copy link
Member Author

Ooooookay, it's not quite the bug I thought, so updating here in case anyone sees this and goes, "oh yes, just flip this switch and all is fine.".

The component gets all the users in an edit context, and checks if they have at least level_1 capabilities. However, if you're a user that doesn't have an explicit role on a site, then you don't have these capabilities listed, and when the component tries to render you in the dropdown list of potential authors, you get the crash.

This can't be fixed in the same way as the other fixes because it's using a different API, so I'm not sure on what the fix would be yet. Investigating further.

@Kilian
Copy link

Kilian commented Jan 15, 2018

Have you seen https://core.trac.wordpress.org/ticket/16841 ? That might provide some additional context/info!

@notnownikki
Copy link
Member Author

That could explain why you're getting the crash! My situation is different, but results in the same error. I'm currently working out if it's one particular user (which would point to the bug you linked, or similar), or if I'm not getting any capabilities back from the API at all. Will keep this issue updated!

@MarkCanada
Copy link

I have that same problem on my test system (WP 4.9.4, GB 2.3.0, TwentySixteen Theme). I disabled all plugins but Gutenberg and still can't edit anything.
For some reason in the user manager it displays under additonal capabilities "frm_view_forms, frm_edit_forms, frm_delete_forms, frm_change_settings, frm_view_entries, frm_delete_entries" so I added another admin user account and used a user switcher plugin and that user has the same problem.

TypeError: Cannot read property 'level_1' of undefined

@Kilian
Copy link

Kilian commented Mar 20, 2018

As of Gutenberg 2.4.0 this is still an issue unfortunately.

@danielbachhuber
Copy link
Member

This was addressed by #6515 and fixed for Gutenberg 2.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Document Settings Document settings experience [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

5 participants