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

Role array without 0 index preventing log from being created #814

Closed
desrosj opened this issue Jan 22, 2016 · 0 comments · Fixed by #824
Closed

Role array without 0 index preventing log from being created #814

desrosj opened this issue Jan 22, 2016 · 0 comments · Fixed by #824
Assignees

Comments

@desrosj
Copy link
Contributor

desrosj commented Jan 22, 2016

Working on a site and noticed debug.log instances where the following would occur:

WordPress database error Column 'user_role' cannot be null for query INSERT INTO wp_stream``

Looked around and tracked it this line in classes/class-log.php

'user_role' => (string) ! empty( $user->roles ) ? $user->roles[0] : '',

After some debugging I found that the roles property of WP_User is not guaranteed to be an array starting with an index of 0. It could be any numerical value.

Attaching a change that prevents this from blocking the log item.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants