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
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | calendar_view-fix-pagination-3345696-13.diff | 1.53 KB | alex0412 |
| #6 | reservation_calendar.mp4 | 8.46 MB | matthieuscarset |
Issue fork calendar_view-3345696
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 2.0.x
changes, plain diff MR !14
- 3345696-pagination-does-not
changes, plain diff MR !12
Comments
Comment #2
matthieuscarset commentedThank 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.
Comment #3
mornel commentedI've just installed version 2.0.5 and I am experiencing the same problems described by alex0412 above.
Drupal version: 10.0.4
PHP: 8.1.14
Pagination doesn't work both on demo calendars and manually created. Turning AJAX on/off doesn't change anything.
To be more exact you can just do one step. For example from main view page you can go back one month, but then doesn't matter if you click on previous, next month or today - nothing happens.
Comment #4
matthieuscarset commentedThank you very much for reporting this issue too.
I am trying hard but I really don't manage to reproduce any error with the pagination.
I need to know what is the configuration of your Views @mornel @alex0412.
Can you please detail how is your Calendar view configured?
Type of content.
Calendar settings.
Field settings.
Filters...etc
Maybe just a copy/paste of the
views.view.your_view_id.ymlwould be enough for me to understand.Lookin forward to hearing from you.
Comment #5
ttnt commentedSame problem here on a fresh install of D10. With or without AJAX doesn't matter, you can go forwards or backwards once, then it's over.
Content type uses a Date range field.
Settings: all default, date field is my date range field.
No filters.
Field settings: in the view I didn't change them.
No errors are logged. Report/status is all green.
I can screenshot all the configuration pages if that's helpful?
Edit: adding my config. Also tried a view with only my date field but that gave the same result. This one has a couple more fields as I already assumed the module worked fine :).
Comment #6
matthieuscarset commentedTY very much for this example.
I have created a node:reservation with field_comments, field_range_date and field_reservable and then, I have imported your View. Finally, I have generated a few nodes with devel_generate (e.g. 20+ node:reservation in the past year).
I can navigate correctly between months without any error being raised.
I am sorry for the inconvenience but I do not manage to reproduce the bug you're having.
I'd need more details about the error.
Any log from Drupal or in your browser's console maybe?
If you have access to the code, can you try to debug step by step in
template_preprocess_calendar_view_pager()?Are you using any custom Twig template for this View, at all? Can you try with a different theme?
Looking forward to hearing from you.
Comment #7
ttnt commentedHello,
I tried changing to the default theme and also enabled/disabled AJAX for the heck of it, no change.
Debugging... I tried looking up how but it seems like a bit of a deep dive for me. I have created modules before but I'm a bit of an amateur... I guess I'd have to use devel and wrap it in kint or something? I got a bit lost in the whole debugging using an IDE :/.
There are ZERO errors on the Drupal / apache side of things.
Anyway, trying to do some hardcore notepad work here:
March
next:
reservation_calendar?previous=1675759899¤t=1678179099&next=1680853899&date_format=custom&date_pattern=F&display_reset=1&calendar_timestamp=1680853899
prev:
reservation_calendar?previous=1675759899¤t=1678179099&next=1680853899&date_format=custom&date_pattern=F&display_reset=1&calendar_timestamp=1675759899
April
reservation_calendar?previous=1675759899¤t=1678179099&next=1680853899&date_format=custom&date_pattern=F&display_reset=1&calendar_timestamp=1680853899
next:
reservation_calendar?previous=1678179099¤t=1680853899&next=1683445899&date_format=custom&date_pattern=F&display_reset=1&calendar_timestamp=1680853899
prev:
reservation_calendar?previous=1678179099¤t=1680853899&next=1683445899&date_format=custom&date_pattern=F&display_reset=1&calendar_timestamp=1680853899
So when I take the next value and type in the following in my browser I go to May:
reservation_calendar?calendar_timestamp=1683445899
So the problem seems to be the "calendar_timestamp" part? If I give the next or previous timestamps (as correctly predicted by the next and previous buttons) along in the URL it correctly moves to the next Month, but then gets stuck again as it again puts the current month timestamp in the URL of the next or previous month.
I hope this can help :)
Comment #8
luluthegeek commentedI 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¤t=1678218608&next=1680893408&date_format=custom&date_pattern=F&display_reset=1&calendar_timestamp=1680893408I have this problem with the themes Olivera and Claro, and AJAX enabled or disabled.
Also tested using the Article content type and the field "created". I post an export of my view below.
Thank you for your help...
Comment #9
matthieuscarset commentedThank 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_demoand 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.
Comment #10
ttnt commentedIs there 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?
Comment #11
alex0412 commentedComment #12
alex0412 commentedI disabled all caches just to make sure that it's not related to that, but the issue is still there.
Comment #13
alex0412 commentedI 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:
The order of this "+" operator is wrong. PHP documentation:
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...
Comment #14
luluthegeek commentedI 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 :
Then, I updated Drupal 9.5.3 to 9.5.4, and the bug appeared again on calendar_view_demo.
Comment #15
alex0412 commentedAh, 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...
Comment #18
pfructuoso commentedI 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
Comment #19
kenrbnsn commentedI applied the diff code (patch) to my site and it fixed the problem. Drupal: 9.5.4, PHP 8.1.16
Comment #20
pfructuoso commentedComment #21
jurgenhaas+1 RTBC on #13, this fixes the problem for me too and I was just about to propose the exact same patch.
Comment #24
matthieuscarset commentedWoua 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.
Comment #25
mornel commentedThank 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!
Comment #26
matthieuscarset commentedI reproduced the bug locally yesterday while working on this other issue.
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.
Comment #28
attisanI'm a bit at a loss here. using the latest dev the issue is still present (running core 9.5.5) - but the patch from MR 12 does not apply (I guess as it is already been merged?).
##edit: same with core 9.5.7. My finding is: navigating into the future works fine. However, navigating backwards works a single time after which the headers are wrong and navigation stalls. navigating into the future somewhat resolves the issue (but jumps over a month).
I will be looking into this as we need this for a client 😅
Comment #29
attisan@mornel
see #3351841: Add weekday classes and week numbers. Would love some reviews 🙏.