Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field sort order can be indeterminate #18542

Closed
wezell opened this issue May 22, 2020 · 5 comments
Closed

Field sort order can be indeterminate #18542

wezell opened this issue May 22, 2020 · 5 comments

Comments

@wezell
Copy link
Contributor

wezell commented May 22, 2020

When we return the list of fields on a content type, we only order by sort_order. We have a bunch of content types that have indeterminate sort orders in their - like the host type below:

dotcms=# select field_name, velocity_var_name, sort_order from field where structure_inode='855a2d72-f2f3-4169-8b04-ac5157c4380c';
       field_name        | velocity_var_name | sort_order
-------------------------+-------------------+------------
 fields-0                | fields0           |          1
 fields-1                | fields1           |          1
 Host Name               | hostName          |          1
 Aliases                 | aliases           |          1
 Tag Storage             | tagStorage        |          1
 Is Default              | isDefault         |          2
 Is System Host          | isSystemHost      |          3
 Host Thumbnail          | hostThumbnail     |          4
 Run Dashboard           | runDashboard      |          5
 Meta Data (Default)     | metaData          |          6
 Keywords                | keywords          |          7
 Description             | description       |          8
 Site Tags               | siteKeys          |          9
 Google Map              | googleMap         |         10
 Google Analytics        | googleAnalytics   |         12
 Add This                | addThis           |         14
 Proxy Url for Edit Mode | proxyEditModeUrl  |         17
 Embedded Dashboard Url  | embeddedDashboard |         18

This means when someone pushes a content type from one server to another, the sort orders can display completely differently based on the database and as soon as the content type is persisted, it will appear to have been reordered.

@nollymar
Copy link
Contributor

PR: #18543

@nollymar nollymar added this to the Bug Sprint milestone May 22, 2020
@nollymar nollymar self-assigned this May 22, 2020
nollymar pushed a commit that referenced this issue May 26, 2020
nollymar pushed a commit that referenced this issue May 26, 2020
* #18542 adds secondary sort crieteria for consistant sorts

* #18542 final the strings

* #18542 Adding ITs

Co-authored-by: Nollymar Longa <>
@nollymar nollymar removed their assignment May 26, 2020
@nollymar
Copy link
Contributor

Passed Internal QA (note to QA) : The best way to test the fix was through ITs. However, it is recommended to use the old starter to verify that the sort order is working correctly.

@nollymar nollymar added the Merged label Jun 3, 2020
@bryanboza
Copy link
Member

Fixed, tested on release-5.3.2 // Postgres and now this appear in the correct order
image

@jcastro-dotcms
Copy link
Contributor

@bryanboza why are the numbers 5 and 6 duplicated in the list?

@wezell
Copy link
Contributor Author

wezell commented Jun 5, 2020

@jcastro-dotcms I think as soon as you "reorder" the fields in the back end, they will de-dupe. The issue was that a lot of customers have data like the above where multiple fields shared the same sort_order and when the fields get pushed from one instance to another, they would magically "re-order" themselves.

What the fix did was add a secondary sort in the SQL by the velocity_var_name so that even if there are multiple fields with the same sort_order their sort will still be consistant across environments. Now, it might initially show as consistantly wrong, but with the secondary sort crieteria, you should be able to fix the order once and then never again.

@wezell wezell closed this as completed Jun 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants