Closed (fixed)
Project:
farmOS
Version:
7.x-1.x-dev
Component:
Farm Groups
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
19 Mar 2018 at 16:02 UTC
Updated:
6 Apr 2018 at 00:19 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
m.stentaSee attached screenshot provided by Rory Fogerty, who reported this originally.
I'm also curious to see if the same issue occurs when assets are in more than one area (the group membership code and the location code are similar, and share some logic).
Comment #3
Permakai commentedWould dearly love to see a resolution of this as its making our transplant list over twice the size it should be.
NOTE: Issue does not occur when asset is in multiple areas
Comment #4
m.stentaThanks for the info @Permakai! The fact that it doesn't happen with multiple locations is good - it means we can probably just look to that system to see how it's handling things differently.
This is high on my list of things to fix. I'm hoping to release a new beta version of farmOS next week, and want to include this fix in that.
Comment #5
m.stentaAh ok - I dug into this and I know what's causing it (and why it's different from the Location handler).
It's because we include an optional "Group" search box in the "Filter/sort" options, which allows you to filter your list of plantings down to those within a specific group (using a "name contains" search type). In order to provide this, the View needs to add an additional relationship to the Group that's referenced, which means an additional join in the SQL query, and that results in duplicate rows appearing in the results.
This isn't happening with the Location handler because we don't need to join in the actual referenced areas in order to include an exposed filter for "Location". This boils down to the fact that areas are taxonomy terms, and the Views module provides a nifty Views filter handler for taxonomy terms that shows them all in a select list. That's not possible out-of-the-box with other entity references in general (so we don't have it for assets like Groups).
So, two ways to fix this... one easy (with a drawback), and one more involved...
Easy way is to simply remove the "Group" search field from the "Filter/sort" (and also the extra relationship that is needed for it). This would fix the issue, but it means that you will no longer be able to filter assets by group name. You CAN still go to the actual Group asset, and see a list of assets within that group there... so it's still possible, just not from the general asset Views.
The more involved way would be to write a custom Views filter handler for asset references (or just for Groups specifically), which behaves similar to the taxonomy filter handler provided by Views. We will need this feature eventually anyway, once we convert areas to assets (see #2363393: Make "Area" into a type of Farm Asset). But it's more work than I have time for right now...
So I think I'm just going to go ahead and remove the "Group" search filter from asset Views - because this is a bug that needs to be fixed ASAP.
Comment #6
m.stentaI've removed that filter from my local testing site, and confirmed that it fixes the issue.
Comment #8
m.stentaFixed.
Comment #9
m.stentaI created a new feature request to restore the exposed group filter (using the more involved approach suggested above): #2955393: Exposed filters for asset and user references