Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
views.module
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
27 Jul 2015 at 14:16 UTC
Updated:
2 Feb 2016 at 10:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
duaelfrComment #2
dawehnerLooks potentially like a right fix, even the code exists exactly like that in D7 as well. We need a strong test coverage for the many to one helper, this is for sure, though.
Comment #3
Anonymous (not verified) commentedThe error indeed goes away, but the filter doesn't work as expected. I always get an empty result list, possibly because the left join might be too restrictive:
LEFT JOIN node__field_list_text node__field_list_text ON node_field_data.nid = node__field_list_text.entity_id AND (node__field_list_text.field_list_text_value = 'ipsum' AND node__field_list_text.field_list_text_value = 'dolor')Comment #4
Anonymous (not verified) commentedRemoving the extra parameters on the left join seems to resolve the issue. I guess they are there for a reason though :)
Comment #5
Anonymous (not verified) commentedComment #6
geertvd commentedFound some issues:
I figured this 'extra_type' parameter should have been the one combining the extra parameters in the left join. This was the case in d7 but has been changed to 'extraOperator' in d8.
This will make #3 look like this
LEFT JOIN node__field_list_text node__field_list_text ON node_field_data.nid = node__field_list_text.entity_id AND (node__field_list_text.field_list_text_value = 'ipsum' <strong>OR</strong> node__field_list_text.field_list_text_value = 'dolor')$extraJoinOperator(I don't like this name any suggestions?)I think this is also an issue in d7.
This is also there in d7, it basically adds a condition which filters on "filter field" = NULL, which seems wrong. we might have to backport this to d7 when this is fixed.
However I don't think we need to add it as a where condition at all since it will be added as a join condition anyway.
Comment #7
geertvd commentedComment #8
lendudeThe fix here looks better then in the related issue, so just added the test coverage from the related issue to this one.
Lets see how it works....
Comment #10
geertvd commentedLooking into why this is failing.
Comment #11
geertvd commentedWhile working on this I created #2561973: Unable to save view with permission filter handler
Comment #12
mgiffordThat other issue is fixed now (which is great).
Comment #13
Valery_Kondakoff commentedThis issue is fully reproducible in every D8rc build I'm testing (including the D8.0.0-rc4). Is there a chance to see this fixed in the final build?
Comment #14
duaelfr@Valery_Kondakoff sadly, no. But if we can find some time to work on this one it could be fixed in 8.0.1 that's planned for December 2.
Comment #15
dawehnerIt certainly doesn't hurt to have a bugfix ready ...
Comment #16
mikeyk commentedI think I have a fix for this.
Unless I'm missing something, most of the SQL code generated in this module is fine however there is an issue with the code for "IS NULL". This is because the SQL code generated is always in the form of $field $operator($placeholder). That is fine for when the $operator is "=" or "!=", e.g. $field = 'value', $field != 'value'. However once the operator becomes "IS NULL" this breaks it because it generates SQL that is $field IS NULL ''. The $placeholder because $value (which is NULL when the IS NULL operator is used), but it is still wrapped in two ' marks which causes problems in this instance. MySQL doesn't like the ' ' and so throws an error.
This patch adds a check to see if the operator is "IS NULL" and then excludes the $placeholder. Fixed the issue for me so would be great to know if this works for others.
Please note the patch file has been a diff from the latest 8.1.x-dev branch so I've added do-not-test to the file.
Comment #17
mikeyk commentedUpdated the patch to the 8.0.x-dev branch - removed do-not-test from the filename of the patch submitted previously.
Comment #18
mikeyk commentedComment #19
mikeyk commentedOkay updated patch. After testing the one I posted earlier I discovered it didn't work correctly once multiple options were selected. This seems to work for that now by fixing the join to an OR rather than AND. The original code was supposed to do this but was setting the wrong variable (extra_type VS extraOperator in JoinPluginBase).
Comment #20
dawehner@mikeyk
Is there a reason you are not going with the patch in #8 which had a test + doesn't use tabs instead of spaces?
Comment #21
mikeyk commented@dawehner
The key reason is that #8 returns a result set that I think is incorrect. On my test site both #19 and #8 return the same result set for multiple selections of "is none of", but different results when you only make one selection.
As far as I can see the issue with the SQL that #8 returns is...............
Say you have two options you can delimit on - Feature and Regular, and we want to select all Node's that are NOT Feature.
If a Node is only a Feature then #8 will not return it (correctly)
However if a Node is both a Feature and Regular then #8 will return it (incorrectly). This should not happen.
So I believe the introduction of the extraJoinOperator and changing the IS NULL operator to <> is incorrect. The only changes I think need to by made to fix the SQL code is...
1. Removing the '' quotes after IS NULL (these are inserted due to the $placeholder code which #19 conditionally removes)
2. Changing $join->extra_type to $join->extraOperator so that the OR works correctly.
If others are getting the same result then perhaps we should look to merge my patch with the test in #8.
And I'll fix up the tab/space issue too.
Comment #22
mikeyk commentedHere is an updated version of the #19 patch with the test from #8 and I removed the tabs.
Hopefully this passes...
Comment #23
lendudeI like the look of this fix, seems more straight forward than the previous fix and unless we can find some testcases where this fix fails, I'd say stick with this.
Some changes I added:
- Fixed a remaining tab
- Added test for filtering on 'not' with multiple permissions
- Added fix for filtering on 'not' with multiple permissions
Multiple permissions were not working when they were from multiple roles, only the last role would be used because of the += used.
Comment #24
dawehnerCan we swap around the logic, so we don't need the boolean negation here? It is a small thing, but it helps people to read the code a bit easier. Nitpick nr2: There is a space missing after the if.
Comment #25
lendudeUpdated per #24.
Comment #27
lendudeBleh, copy/paste truncate.
Comment #28
dawehnerDo you mind documenting why we use array_merge here ... to ensure that we never result into duplicate RIDs ...
Comment #29
lendude@dawehner something like this? Updated the surrounding comments to make clear we are dealing with role IDs, not roles.
Comment #30
dawehnerNice!
Comment #31
mradcliffeThis may be fixed on commit. I do not think there should be a comma preceding the clause "that".
"Get all role IDs that have the configured permissions."
Comment #32
alexpottCommitted 6e62a62 and pushed to 8.0.x and 8.1.x. Thanks!
Slightly reworked the comments...