With a clean install of Drupal, Draggable Views --dev and dependencies, the sorting hierarchy is broken. I'm doing this with Ajax off and using the native sort and hierarchy.

If you do the below, the sort order breaks and the table has to be truncated because sometimes a node will have itself as its parent.

1.
2.
3.
4.
5.

Then

1.
-2.
-3.
4.
5.

Then

5.
-1.
-2.
-3.
4.

The resulting weights and parents after the last change looks to be random whereas the latest stable release respects the new sort.

Comments

niallmurphy-ie created an issue. See original summary.

trumanru’s picture

Looks like true. I've faced to same problem - random sorting with -dev version.

David_Rothstein’s picture

Title: Latest Dev is broken.. Easily recreatable sorting error. » Sorting using the native handler is broken in the latest dev version, especially when hierarchy is used
Status: Active » Needs review
StatusFileSize
new7.45 KB

There are two related problems here:

  1. Sorting using the native hierarchy handler is broken pretty much completely, as described in the examples above.
  2. Regular sorting using the native handler is somewhat broken. For example, if you load up a view with several new (not-previously-sorted) items in it and then save immediately without drag and drop, the ordering can get out of whack. That's because the row weights are not set correctly on form load.

Both of these issues are a result of #2174287: Order not saved when using show row weights mode (although the second is more of a preexisting problem that never mattered much before that issue went in).

The two issues are very closely related, so here's a patch that fixes both at the same time. The fix is a bit complicated, but the details are explained in the code comments.

damienmckenna’s picture

David_Rothstein’s picture

Note: The above test failure looks like it's preexisting on the branch (see https://www.drupal.org/pift-ci-job/450761) and therefore not related to this patch. I also couldn't even reproduce it locally.

damienmckenna’s picture

StatusFileSize
new8.53 KB
new1.14 KB

This should resolve the test failure.

David_Rothstein’s picture

Ah, that looks like a good fix - basically the problem is that the previous test was assuming clean URLs. (Still a preexisting test failure though, and not related to this issue, although obviously no harm in fixing it here.)

sgdev’s picture

I saw this references issue #2174287. @David_Rothstein, you mentioned the commit seems to have broken some things.

Is the issue specifically in situations where sorting is being done with both parent and child items? If I attempt to use the patch in #2174287 and have no hierarchy, it works as expected.

David_Rothstein’s picture

@ron_s, yes, mainly when there are parents and children. But see point #2 in my above comment for a scenario where it can break even without a parent-child hierarchy.

sgdev’s picture

Ah yes, I see. Thanks for pointing that out. I'm fairly certain I did not previously test that scenario.

sgdev’s picture

StatusFileSize
new7.78 KB

The patch in #6 no longer applies cleanly since the test fixes have been committed elsewhere. They are already part of the current version of 7.x-2.x-dev.

Attached is an updated patch that removes the changes to draggableviews.test.