Closed (fixed)
Project:
DraggableViews
Version:
7.x-2.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
27 Feb 2012 at 18:53 UTC
Updated:
29 Jan 2015 at 21:25 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
terbs commentedHere's the attached patch file. Basically in the draggable_views_join_handler.inc file where we're getting the sort field it's like this
However, using the key "weight" is unreliable because other modules or fields might be named weight. For example, the taxonomy weight field, which is what was causing the break in my environment. I've rewritten this file to more intelligently determine exactly which field is the draggable views field instead of just relying on "weight".
Comment #2
ygerasimov commentedThere was similar issue #1389440: Undefined index: draggableviews_setting_view in draggableviews_contextual_links_view_alter() (line 180 of draggableviews.module) where function draggable_views_get_draggable_sort() has been created. Possibly we can reuse it.
Comment #3
gumanist commented@aiquandol
Could you provide step-by-step instuction to reproduce an issue?
Comment #4
terbs commentedPut a bunch of taxonomy terms and nodes in a site, then order a view by both taxonomy term weight and draggable views weight.
Since both fields are named "weight", conflicts will occur because draggable views doesn't know which "weight" field to use in the handler.
Comment #5
ygerasimov commentedI have created 4 terms. Created a view to sort terms and added in sort criteria taxonomy weight. In result I can sort terms, but no duplicates detected. If Taxonomy weight is first and then Draggableviews weight, nothing changed after I save the order and that is expected behavior.
@aiquandol could you please provide more details about settings of your view that produces duplicates? Maybe you can export it here. This might help.
Comment #6
terbs commentedSorry if I'm being unclear. The issue can be seen most clearly in the code itself. This is in draggable_views_join_handler.inc
Lines like this, where we're selecting a member of the $view_query->view->sort array using the key ['weight'], is where the problem lies. ['weight'] is a vague selector that can match multiple sort criteria, not just the draggable views weight sort. If you add "Taxonomy: Weight" to your sort criteria first, then "Taxonomy: Weight" gets the ['weight'] key in the sort array and draggable views gets the key ['weight_1'].
It's the fact that we're using the vague selector ['weight'] to determine which field is the draggable field that causes a lot of errors like duplicates.
Attached is a view for reference. Import it, then put a dsm() or some kind of variable dump in draggable_views_join_handler.inc right above line 31
You'll see in the variable dump that the draggable views handler has the key ['weight_1'] but the if statement is using the key ['weight'] (which is the taxonomy weight sort), which is causing the view to bug out and fail in weird ways (one of which is creating duplicates).
The solution proposed in the patch is to find the draggable sort field's key in a more robust way instead of just $view_query->view->sort['weight'] (which will fail).
Comment #7
ygerasimov commentedYes, now I finally got duplicates locally! @aiquandol, thanks for your patience. Please test attached patch that fixes pointed issue.
Comment #8
ygerasimov commentedComitted.
Comment #10
fernly commentedI can confirm this issue is still occurring using the dev version of 2013-Sep-30.
Context:
A view is displaying product display nodes and contains filters and other sort criteria in an exposed filter block. This is the front-end display. After saving the custom order using the drag functionality in a second views display (back-end), duplicates start popping up in the original front-end display. Distinct doesn't work here.
Comment #11
fernly commentedApparently it's another issue. I take it back :-)
Comment #12
pedromvpg commentedIt looks like this is still happening on 7.x-2.x-dev (2014-Dec-05). It works fine the first time but after a couple of saves I have 5 different instances of the same node on the draggable view page. All of the above patches are rejected in this version.
Anyone else having this problem?
Anyone know of any alternatives? Using earlier versions of the module create an "Illegal Choice" problem as seen here https://www.drupal.org/node/1537532.
Comment #13
pedromvpg commentedStill occurring in version 7.x-2.x-dev (2014-Dec-05).
Comment #14
istryker commentedChanging the title marking it as fixed. We cannot have multiple issue (that are similar) in the same issue. It gets confusing. @pedromvpg open another issue if you are still having problem and add this issue as a related issue.