Pagination does not work

Created on 3 March 2023, over 1 year ago
Updated 18 April 2023, over 1 year ago

Problem/Motivation

I'm not sure from which version on this bug appears, but on 2.0.2 at least everything worked. After an update to the most current version (which is at the moment 2.0.5) the pagination doesn't work anymore.

Steps to reproduce

Reproduction steps not even necessary, the bug can be seen on the official demo site as well: https://magnificent-caramel-9d8164.netlify.app/events-calendar/
Clicking on the next or previous month doesn't do anything.

But just to be complete: I guess there's nothing special to do to be able to reproduce it. Just create a calendar view as described in the documentation. It doesn't seem to depend on any specific configuration combination.

Environment:
- Drupal: 9.5.4
- PHP: 8.1.13

πŸ› Bug report
Status

Fixed

Version

2.0

Component

User interface

Created by

πŸ‡©πŸ‡ͺGermany alex0412

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.

  • Issue created by @alex0412
  • Thank you for reporting this issue. I am not sure to understand though.

    Are you talking about the navigation by month or another pager ?

    If you view uses Ajax, any error in the console ?

    Can you share more info about how your view is configured ?

    Regarding the demo, it s a static site and no dynamic things such as the pager or search work. There should be a disclaimer to explain it, sorry about that.

  • Status changed to Postponed: needs info over 1 year ago
  • πŸ‡«πŸ‡·France luluthegeek

    I am experiencing the same problems with a fresh install of Drupal 9.5.4 and calendar_views 2.0.5.

    I can change month once with the pager, but then any new action is not successful and I stay on the same month. The previous, next and today links on the pager all have the same URL :

    evenements?previous=1675799408&current=1678218608&next=1680893408&date_format=custom&date_pattern=F&display_reset=1&calendar_timestamp=1680893408

    I have this problem with the themes Olivera and Claro, and AJAX enabled or disabled.

    Thank you for your help...

  • Status changed to Active over 1 year ago
  • Thank you for reporting the issue with details.

    I am still trying to reproduce the error. I've made a fresh install on Drupal 9.5.3 with version 2.0.5.

    Installed calendar_view_demo and tested the Editorial calendar view.

    Pagination links work all the time, even after multiple clicks, meaning the current timestamp is correct in parameters.

    Trying to investigate in code directly but I can't figure out what cause your issue with the timestamp.

  • πŸ‡§πŸ‡ͺBelgium herrzhull

    Is the a chance it's a Drupal 9.5.4 thing? My test was on 10.0.4. And perhaps as not everyone is reporting the issue it's a recent thing?

  • πŸ‡©πŸ‡ͺGermany alex0412

    I disabled all caches just to make sure that it's not related to that, but the issue is still there.

  • πŸ‡©πŸ‡ͺGermany alex0412

    I think I have found the bug.

    It's inside the "template_preprocess_calendar_view_pager" preprocess function, where the query params are "merged" with the correct "calendar_timestamp" param for the next/prev/reset link:

    '#url' => Url::fromRoute($route_name, [], [
      'query' => $parameters + ['calendar_timestamp' => $parameters['next']],
    ]),
    

    The order of this "+" operator is wrong. PHP documentation:

    The + operator returns the right-hand array appended to the left-hand array; for keys that exist in both arrays, the elements from the left-hand array will be used, and the matching elements from the right-hand array will be ignored.

    As the "calendar_timestamp" key was already inside $parameters, the intended override didn't work. The fix is easy, just revert the order.

    Why you can't reproduce this bug @matthieuscarset is weird though...

  • πŸ‡«πŸ‡·France luluthegeek

    I think the bug appeared with the update from Drupal 9.5.3 to 9.5.4.

    I downgraded my Drupal 9.5.4 to 9.5.3 and installed calendar_view_demo : all is working fine, and the links in the pager are ok :

    next : /calendar?created=-1%20year&title=&type=All&status=All&langcode=All&previous=1680300000&current=1682892000&next=1685570400&date_format=custom&date_pattern=F&display_reset=1&calendar_timestamp=1685570400
    reset : /calendar?created=-1%20year&title=&type=All&status=All&langcode=All&previous=1680300000&current=1682892000&next=1685570400&date_format=custom&date_pattern=F&display_reset=1&calendar_timestamp=1677625200
    previous : /calendar?created=-1%20year&title=&type=All&status=All&langcode=All&previous=1680300000&current=1682892000&next=1685570400&date_format=custom&date_pattern=F&display_reset=1&calendar_timestamp=1680300000

    Then, I updated Drupal 9.5.3 to 9.5.4, and the bug appeared again on calendar_view_demo.

  • πŸ‡©πŸ‡ͺGermany alex0412

    Ah, that's interesting! Maybe this commit from 9.5.4 is related to it, at least it's about view pagers: https://git.drupalcode.org/project/drupal/-/commit/3664a3d4b49f900f617d9...

  • First commit to issue fork.
  • @tar_inet opened merge request.
  • πŸ‡ͺπŸ‡ΈSpain tar_inet

    I tried in Drupal 9.5.2 and I canΒ΄t replicate it either but I did in 9.5.4.

    Fix #13 makes sense and works to me so I created a PR from it to help on the process. I added @alex0412 in the comment of the commit to make sure he gives attribution
    https://git.drupalcode.org/project/calendar_view/-/merge_requests/12

  • πŸ‡ΊπŸ‡ΈUnited States kenrbnsn New Jersey

    I applied the diff code (patch) to my site and it fixed the problem. Drupal: 9.5.4, PHP 8.1.16

  • Status changed to RTBC over 1 year ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    +1 RTBC on #13, this fixes the problem for me too and I was just about to propose the exact same patch.

  • @tar_inet opened merge request.
  • Status changed to Fixed over 1 year ago
  • Woua thank you very much all for finding and fixing the issue. I definitely did not manage to reproduce it...

    I'm merging the changes and it will be shipped in a new release soon.

  • πŸ‡΅πŸ‡±Poland mornel

    Thank you guys, works for me too @ Drupal 10.0.4!

    Small suggestion: it would be nice to have a class on the current day. Cheers!

  • I reproduced the bug locally yesterday while working on this other issue ✨ Add support for week calendar display Fixed .

    I have fixed the pagination by changing some things in the way we retrieve the calendar timestamp (e.g. getCalendarTimestamp() method).

    The final fixed version will be release soon - depends on the other issue.

  • πŸ‡¦πŸ‡ΉAustria attisan Vienna

    I'm a bit at a loss here. using the latest dev the issue is still present - but the patch from MR 12 does not apply (I guess as it is already been merged?).

  • πŸ‡¦πŸ‡ΉAustria attisan Vienna

    @mornel

    Small suggestion: it would be nice to have a class on the current day. Cheers!

    see ✨ Add weekday classes and week numbers Fixed . Would love some reviews πŸ™.

  • Status changed to Fixed over 1 year ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024