symphonycms/symphonycms

Backend publish index table unambiguous sorting

jurajkapsz opened this issue · 13 comments

Affected Symphony version(s) : 2.7.7 (all?)
PHP version(s) : 7.2
OS(es) : All

Don't know how much it is related to #2498 - guess the same issue but this time concerning backend publish index - but:

Use case
Having paginated section entries in a publish backend index, sorted by a field (column) which has the same value across all or most of the entries, e.g. a yes value checkbox field.

Issue
Not all entries are shown when paginating the index table; entries are randomized or being repeated on subsequent pages.

Expected
To be able to browse through all entries in section.

I can't replicate this issue.

What about some extension overriding the sort order?

I can't replicate this issue.

Also @jonmifsud confirmed this on gitter chat that he came across this a few times.

My original posting is right above that comment.

Edited: Actually I came across this for the first time in years. I can't share a sample of the data, because it's private data; basically it's a list of users with some yes / no attributes and associations (association fields).

I understand. I just had another look and I'm using Entry Relationship Field on that site.

I'm sure @jonmifsud 's answer will be correct. 💯

Guys, I can further specify, that:

  • When I filter the index through an association (list associated entries), this issue does not occur, everything is fine;
  • When I don't filter the index - just listing through the whole section; entries having the same
    "yes" value (or "no" in my case, but that does not matter I would say) and sorting by such a column - it does occur.

So the issue is not related to filtering, but only to sorting ???

I confirm some weird behaviour.. I'll investigate on Thursday.

So the issue is not related to filtering, but only to sorting ???

I believe so. If I sort unfiltered section, it does happen; if a filtered section, it does not.

I think I've found why. It's an old thing that I almost forgot: ORDER BY clause are non-deterministic.

Since a checkbox can only contain 3 values (NULL, 'yes' and 'no') the order is not guaranteed, so position 11 does not always have the same value in it. It is less noticeable for inputs, since they generally contain different data.

I remember having to patch datetime field for this exact problem, because we were having multiple equal dates.

@michael-e I wonder if you ever had such problems with your big system ?

@nitriques Now that you mention it… Yes, I also have a "date field hack" in my big system, and the private commit is called "Prevent random sort results for identical dates". Guess what? I added sorting by system ID. :-)

@nitriques Is the Fixed in 3.0.x label correct? I am thinking if it shouldn't be 2.7.x...

@jurajkapsz Yes it is fixed in 3.0.x (since the fix is different b1e668d) but it should also be fixed in 2.7.x when #2872 will be merged.