Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When unhiding the extended taxonomy functionality of Gallery_Collection, see issue Gallery Containers (http://drupal.org/node/1037002), and allowing one gallery to have more than gallery_collection term, drag and drop sorting is not working properly anymore. As a matter of fact, the sort order for the particular term being sorted will be lost.
What happens is that the existing sort order for the given taxonomy term will be deleted before the new sort order is inserted, and inserting the new sort order will run into primary key violation and not be inserted.
Comment | File | Size | Author |
---|---|---|---|
#2 | node-sorting-with-multiple-collections-1289528-2.patch | 986 bytes | Moloc |
Comments
Comment #1
Per Jansson CreditAttribution: Per Jansson commentedOne fix for this is the following:
The table holding the sorted galleries is media_gallery_weight, easy to check.
In the file
media_gallery.pages.inc line 184 to 208 approx we find the following function for reordering galleries
Line 189 :
returns a result that will violate the key constraints of media_gallery_weight and when this happens, first your sort order for the term you are sorting will be deleted and then when inserting the new one it does not work and you get an SQL exception (in the ajax calls), thereby leaving you with a deleted sort order but not updated. This happens if there are galleries with more than one gallery collection taxonomy term and as soon as the primary key constraint is violated. It does not happen immediately, don't be fooled by it looking smooth.
One way to fix the SQL above is to use SELECT DISTINCT, another is to use the full primary key in media_gallery_weight, nid and tid, in the LEFT JOIN condition, rewriting the left join:
This solution has also been posted under the issue Gallery Containers (http://drupal.org/node/1037002), which issue describes how to unhide the taxonomy.
Comment #2
Moloc CreditAttribution: Moloc commentedThis issue is only reproduceable, if you change the default media_gallery content-type. If you change the unlocked media_gallery_collection field to allow more than one collection-terms be chosen, the mentioned select statement is wrong and returns not the correct entries.
The applied patch fixes that.
The patch uses the mentioned LEFT JOIN condition, as this will fetch the correct entries.
Using DISTINCT is wrong and will result in the same behavior as before.
To reproduce this bug, you should also apply the patch in #1228094: Gallery rearranging is not stored.
Comment #3
Per Jansson CreditAttribution: Per Jansson commented@Moloc
Yes, SELECT DISTINCT would be wrong. Thanks for pointing out (and writing the patch)
Comment #4
lsolesen CreditAttribution: lsolesen commented