Views Pager includes duplicates with Random Sort

Created on 28 February 2017, over 7 years ago
Updated 12 January 2024, 5 months ago

Steps to recreate:

- Install Drupal 8x
- Create 50 dummy pages
- Create a view (either page or block)
- Set the view to show the field title (or teaser content)
- Add sort criteria as Global: Random (asc)
- Make sure no other sort criteria is listed
- Add a pager to show 5 items (Full | Paged, 5 Items)

Navigate to the view that you have created. This should results in showing 50 unique nodes being randomly sorted and displayed 5 per page.

What actually happens when clicking through pager is that we get duplicates appearing. It would appear that the pager is requesting 5 nodes and sorting these by random. The next pager repeats this request, resulting in duplicates being pulled through. The nodes are not seeded in a sequence between pages.

Using AJAX makes no difference the issue is present in both AJAX and Non AJAX views.

I noticed this was also an issue Drupal 7 with the solution being available as a module:
https://www.drupal.org/project/views_random_seed β†’

Unfortunately this module in not available for Drupal 8.

✨ Feature request
Status

Needs work

Version

11.0 πŸ”₯

Component
ViewsΒ  β†’

Last updated about 16 hours ago

Created by

πŸ‡¬πŸ‡§United Kingdom sittard

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¬πŸ‡§United Kingdom john.glynn.davies

    Looks like the Views Random Seed module is now available for D8, D9 and D10.

    https://www.drupal.org/project/views_random_seed β†’

  • Status changed to Needs work 5 months ago
  • πŸ‡·πŸ‡ΊRussia kostyashupenko Omsk

    Bump. This is still an issue in Drupal 10.2

    I just have generated several nodes of some content type -> then I created new view with random sorting (no matter if Ajax enabled or not).
    Look at `16` number on the gif above, it's often appears on several pages.

    Moreover, here is another use case.
    Let's say we have some taxonomy terms of some vocabulary. And some terms has same weight. And guess a view which is displaying those terms with the sorting only by weight (no matter asc or desc and no matter if ajax enabled). In the end some of the terms will be duplicated on different pages.

  • πŸ‡·πŸ‡ΊRussia marassa Moscow

    @kostyashupenko, the core developers clearly don't agree that this is an issue. And with a contrib workaround available - https://www.drupal.org/project/views_random_seed β†’ - who cares?

Production build 0.69.0 2024