Affects D8 version only (afaik remember):
Scenario: using published or has role filter
Unselect all roles. Save the filter settings.
Without patching, get this:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '))) ORDER BY node_field_data_created DESC LIMIT 11 OFFSET 0' at line 4: SELECT node_field_data.created AS node_field_data_created, node_field_data.nid AS nid FROM {node_field_data} node_field_data WHERE (node_field_data.status = 1 OR (node_field_data.uid = 1 AND 1 <> 0 AND 1 = 1) OR 1 = 1 OR 1 IN (SELECT ur.entity_id FROM {user__roles} ur WHERE ur.roles_target_id IN ())) ORDER BY node_field_data_created DESC LIMIT 11 OFFSET 0; Array ( )
See patch for fix.
Note, I believe this also affects the current user filter however I didn't yet think of a good default behavior for that when there are no roles selected.
See attached patch for "Published or has role" filter.
Comment | File | Size | Author |
---|---|---|---|
#13 | D8_views_published_or_has_roles-Prevent_Syntax_error_when_no_roles-3023216-13.patch | 1.62 KB | joseph.olstad |
Comments
Comment #2
joseph.olstadComment #3
joseph.olstadhere is a better, safer patch.
Comment #4
joseph.olstadComment #5
albertski CreditAttribution: albertski at Xeno Media, Inc. commented- Instead of doing a return can you just do an else statement for the other expression
- Can you update your comment to something like "If there are no roles selected, not querying on roles."
Comment #6
joseph.olstadyes definately, good call, that would be a better patch.
I will spin up a new patch.
Thanks
Comment #7
joseph.olstadComment #8
joseph.olstadComment #9
albertski CreditAttribution: albertski at Xeno Media, Inc. commentedCan you fix the coding standard issue:
Also, can you fix the comment
// No role was selected, default to this behavior.
Can you change it to something likeIf there are no roles selected, not querying on roles.
(Sorry, just not a fan of "this behavior").Comment #10
joseph.olstadComment #11
albertski CreditAttribution: albertski at Xeno Media, Inc. commentedCan you fix the comment as well.
Comment #12
joseph.olstadI did change the comment to exactly what you suggested.
If there are no roles selected, not querying on roles.
Comment #13
joseph.olstadah, maybe not exactly
here it is.
Comment #15
albertski CreditAttribution: albertski at Xeno Media, Inc. commentedNice find and nice fix. Thanks!
Comment #16
joseph.olstadHi Albertski, how about tagging a release candidate ? or beta tag ? 8.x-1.0-beta1
?
The next issue is to resolve the access violation for the Current User filter, same problem that this issue has.
but I don't have a fix for that one.
Comment #17
joseph.olstadComment #18
joseph.olstadsee similar issue for the Current User Has Role filter #3023688: CurrentUserHasRoles - Prevent Syntax error or access violation when no roles selected