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

Ensure that root pages are always shown in the correct order #5966

Merged
merged 3 commits into from May 4, 2023

Conversation

Toflar
Copy link
Member

@Toflar Toflar commented Apr 17, 2023

I'm having an issue with the page tree displaying the root pages in a different order for a restricted user group rather than the admins. This is because we call updateRoot() at all sorts of different places where the array is not always sorted by sorting. I've fixed this now by always ordering within updateRoot() in case there is a sorting field and we do not have any visibleRootTrails. Because if we do, it means $this->root contains an ID which is not on top-level in which case we cannot order by sorting anymore - this would result in a wrong order as well.

So if your user group has page mounts that only have root pages selected, you now always have the same order as the admins do - guaranteed.

@github-actions github-actions bot added this to the 4.13 milestone Apr 17, 2023
@github-actions github-actions bot added the bug label Apr 17, 2023
Co-authored-by: Martin Auswöger <martin@auswoeger.com>
@leofeyer
Copy link
Member

Is there a way to reproduce the issue, so I can validate the changes?

@Toflar
Copy link
Member Author

Toflar commented Apr 18, 2023

It depends on how the database returns the results. But here:

  • Add 3 root pages
  • Add a user group and only assign it 2 of those root pages as page mounts
  • Switch between the admin user and a user assigned to that group

Either you see the order of the root pages is not the same or you don't. It depends on the order the IDs are added to root and returned from the DB in some of the Database::getParentRecords() or eliminateNestedPages() calls. That's why I put the sorting to updateRoot() - it's always correct then.

@leofeyer leofeyer changed the title Try to improve root order Ensure that root pages are always shown in the correct order May 4, 2023
@leofeyer leofeyer merged commit 7d934b4 into contao:4.13 May 4, 2023
17 checks passed
@leofeyer
Copy link
Member

leofeyer commented May 4, 2023

Thank you @Toflar.

@Toflar Toflar deleted the fix/root-order branch May 4, 2023 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants