Record Sorting & Spontaneous Re-ordering

5 posts by 2 authors in: Forums > CMS Builder
Last Post: June 15, 2015   (RSS)

By In-House-Logic - June 10, 2015 - edited: June 11, 2015

We have a smart, long-time client with a CMS Builder editor housing around 1300 records, about 1000 of which are visible to the public. They are arranged using a manual DragSortOrder but he does use the "Insert Record Here" plug-in.

He has been concerned for some time that the items in this list seem to spontaneously change their order. Some items remain fine for ages, while other groups seem to rearrange themselves all of  a sudden. This has an effect on the public-facing pages also.

The table order is set to DragSortOrder DESC. Removing the DESC does trigger an auto-reorder and greatly affects the order of the items in the table.

Q: What effect should DESC have on this sorting method? I would not have expected it to do anything.

Q: Would removing (and manually resorting the entries) have any impact on his concerns?

Q: Has spontaneous re-sorting been reported anywhere before?

Also, I noted that on the public-facing pages, the main display of these records uses no sorting parameter in the query. Meanwhile, the search result page which shows a subset of the same data uses the dragSortOrder DESC in the query. He's not complained about their display.

EDIT:  The client describes the behaviour as:

Sometimes many items in a set get out of whack. Other times the jump as a block. Other times still, a bunch will jump far away (like 10+ slots).

Any suggestions would be greatly appreciated.

Jayme

By Dave - June 11, 2015

Hi Jayme, 

Thanks for the report, I haven't heard of that one before.

How dragSortOrder works is when you add a record it sets the 'dragSortOrder' field to a large number such as 1434055505.

The number is actually 'unixtime' (the number of seconds since 1980).  So if you add one record a second each one will have a number one greater than the one before.  It also renumbers the existing records from time to time using increments of 10.

When you sort the default is ASC or ascending order, but you can also specify DESC for descending order.  So that will control if new entries get added to the top or bottom and reverse the order of any existing records.  Since you're sorting ascending (1,2,3) or descending (3,2,1).

If no sort order is specified on viewer getRecords calls it usually loads the sort order from the Section Editors config so everything matching up on the front and back ends.

I have a few suspicions about what could be going on.  Can you try adding this debug code to the plugin (it will show the current sort order on each record and the sort order that will be inserted): 

// create link
$addLink = "?menu=$tableName&action=add&dragSortOrder=$newSortOrder";
$actionLinks .= "<br/><a href='$addLink'>{$GLOBALS['CRH_LINK_NAME']}</a>";
$actionLinks .= "<br/>This order: {$record['dragSortOrder']}, Create as: $newSortOrder";

Next, can you let me know which version of MySQL they are running (listed under Admin > General at the bottom).

Also are they using the Save & Copy plugin as well?

Let me know what you find, thanks!

Dave Edis - Senior Developer
interactivetools.com

Hi Dave,

Thanks for the explanation of how this works. I always assumed that the order was more a simple index like what Joomla!/Mambo used to use. But the timestamp makes a lot of sense.

In answer to your questions:

1 - Yes, they are using both the createRecordHere.php plugin as well as the saveAndCopy.php/.js.php plugin. Plus there's a listRefreshFix.php which I've not noticed before.

2 - The server script versions are: PHP Version  PHP v5.3.29 -    Database Server  MySQL v5.5.3231.0 (Max Connections: 500)

3 - I've added the debug code to the plugin and it's now showing the current and proposed sort order. Not sure what you may need me to report beyond that. The current sort order is generally in DESC order from the samples I've looked at.

Looking forward to sorting this. It's become a serious issue for this client.

Jayme

Thanks Dave. Understood.

Being able to see the sort order will make this a great deal easier to track.

Will let you know what we find.

Jayme