Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The views pager constructed in date_views/theme/theme.inc makes incorrect assumptions for the "next week" link.
This causes problems where your week view will jump from December 2012 to January 2012 when pressing next.
This is the case because 2013 starts on a tuesday.. It will calculate the next weeknumber ( = 1) and the month is derived from the first day of the next week (2012)
I have implemented a small fix, it's not really elegant but it works for me.
Comment | File | Size | Author |
---|---|---|---|
#34 | date-pager-next-prev-1874422-34.patch | 1.69 KB | SeanA |
#23 | week-pager-next-prev-year-fix-1874422-23.patch | 2.68 KB | danwonac |
Comments
Comment #1
bluetegu CreditAttribution: bluetegu commentedThanks. Included is a patch that fixes the pager issue using a different approach, and also fixes the default 'current date' value for views. The patch replaces 'regular' year with ISO year to match the ISO week used.
Comment #2
rv0 CreditAttribution: rv0 commented@bluetegu
I'm not sure if you can assume ISO week numbers, as thats a setting in the backend? Your patch does look a lot more elegant.
also, I don't know why the testbot isn't testing our patches?
Comment #3
bluetegu CreditAttribution: bluetegu commenteddate('W') is ISO week, hence we need date('o') for ISO year. Prior to patch, we get 01 for week and 2012 for year. After patch we get 2013 for year and 01 for week, as should. I'm still hoping the testbot will do its thing.
Comment #4
bluetegu CreditAttribution: bluetegu commentedAnother fix: the default week value doesn't pad the week number, e.g. produce W02 rather W2 which is wrong. Here is the updated patch.
Comment #6
brockfanning CreditAttribution: brockfanning commentedAs the end of the year nears, it looks like this bug is rearing its ugly head again. Here is a compilation and re-roll of the work done by bluetegu so far.
Comment #7
vijaycs85Thanks for the patch @brockfanning & @bluetegu.
Nice, fix. So 'o' is - ISO-8601 year number. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead. (added in PHP 5.1.0)
Looks good to me.
Comment #8
podarok#6 commited to dev
Thanks!
Comment #11
Anonymous (not verified) CreditAttribution: Anonymous commentedHello i installed patch #6 and it seemed to work. But now im getting problems in year 2016 when using next week. Next is linking to the week which is actual showing.
Comment #12
danwonac CreditAttribution: danwonac commentedI'm experiencing similar issues with the latest dev version paging forward and backward weeks with block views between 2014 and 2015.
The issue appears to be with how the previous/next arguments are generated. The ISO week number for 29th-31st December 2014 is 1 (as is returned by date_week()) however the argument is created using date_format($date, 'Y-\W') which for any of these particular dates is of course 2014.
Hence, paging from week 52 of 2014 to the next week generates the argument ?mini=2014-W01 and paging from week 2 of 2015 to the previous week generates the argument ?mini=2014-W01 (because the date is of course the same, December 29th 2014).
I've modified date\date_views\theme.inc to test the year and week. If the month is December but the week is 1, add 1 to the year:
This has fixed it for me.
Alas, haven't quite figured out how to make a patch yet but should be close.
Comment #13
danwonac CreditAttribution: danwonac commentedHere's a better patch for #12.
Comment #14
danwonac CreditAttribution: danwonac commentedHmm, the previous week pager doesn't seem to be working either. This looks like it is because there is no granularity specified when getting the previous and next dates when skip_empty_ages is empty:
Rolled another patch to incorporate #12 and this too.
Comment #15
shortspoken CreditAttribution: shortspoken commentedThanks! #14 fixed it for me!
Comment #16
BBCI'm not using ISO-8601 week numbers on my site and found that the changes in #6 actually created the problem this issue was intended to solve.
In my case, hitting next when viewing the last week of the year caused the view to jump to the following year. In other words, selecting the next week button on December 22, 2014 was taking users to December 28, 2015 rather than to December 29, 2014.
I tried the patches in #12-14 here and they didn't help. Looking back at #6, I found that reverting the changes to theme.inc (using Y-\W instead of 0-\W) got the previous and next buttons working as expected again.
Comment #17
Anonymous (not verified) CreditAttribution: Anonymous commented#14 is still not working for me. 2016ff still causing problem when using week pager on a view. The next button does not change the week, it loads every time the actual showing week. Can someone confirm and reopen this?
Best regards, Edin
Comment #18
danwonac CreditAttribution: danwonac commentedThe latest dev version is working for me with patch from Undefined variable: granularity in date_views_plugin_pager->query()
Comment #19
schifazl CreditAttribution: schifazl commentedI confirm what danwonac said in #18, dev version + the other patch works flawlessly!
Comment #20
nikita.izotov CreditAttribution: nikita.izotov commentedProblem
I have by week pager, so when i click to the 2015-W53 and then next it jumps to 2016-W02, so the first week is gone. and later all that year it counting weeks from 2nd. Nothing bad, just simple drupal numbers, but... i have this issue on calendar and since that is happening i've lost some events
Selecting 23.02.2016 on calendar (it is in the8th week of 2016) shows 2016-W08 in pager link and Week of Monday, February 15, 2016. So as calendar show 15.02.2016 belongs to 7th week, not to 8th what i was selected.
Comment #21
jlea9378 CreditAttribution: jlea9378 commentedI tried patch #14 with the latest dev release of Date and it didn't work flawlessly for me. Clicking the Next button in the year view jumps me from January to March! What happened to Feb?? If I click Next again, it skips April and jumps me to May! And so on down the line... but if I click Prev I can get to the skipped months. The week view is working similarly, skipping weeks when clicking Next. The day and year views work fine -- no skipping.
Using:
Calendar 7.x-3.5
Date 7.x-2.9-beta2+2-dev (2015-Jan-05)
Comment #22
Anonymous (not verified) CreditAttribution: Anonymous commentedi can confirm #20 too.
i used latest dev + #12. i also found that if u set Use ISO-8601 week numbers in 2016, prev button is jumping two weeks back and next ist linking to the active week.
Comment #23
danwonac CreditAttribution: danwonac commentedMy use case is with php v5.3.29, regional settings using ISO-8601 week numbers and latest dev version.
I have found that the next pager from 2015-W53 is not working correctly.
In the date_api.module, the function date_iso_week_range() appears to fail under the specific circumstance that the 28th of December is a Monday (just like 2015). date_modify() attempts to add one Monday to the date but the function doesn't add a week if the day is already a Monday (at least in the version of php I'm running (5.3.29).
date_modify($min_date, '+1 Monday'); // Fails to add a week when $min_date is already a Monday
This means that the incorrect date is returned for the range for all dates of the next year. I've no idea whether this occurs on other versions of php but ensuring a Monday is added is necessary which I did with
Two related issues are also required to fix this:
Patch #35 from Calendar block Next/Prev navigation broken
@brockfanning's patch #6 of this issue has been partially applied to the latest dev version, the fix in date_views_argument_handler_simple.inc is there. The other fixes to theme.inc and are not applied but still required. The code changed a bit in the latest dev version where this was previously applied.
I've rolled these all into one attached patch.
I've tested this with a view paging back and forth for 2013, 2014, 2015 and 2016 and it all works as expected.
I suspect the date_modify() issue will fix @edin.dedagic's issue with jumping two weeks back and no weeks forward, it's the same symptom of the 1st week of the year being a week behind what it should be. Similarly #20 from @nikita.izotov.
Comment #24
Anonymous (not verified) CreditAttribution: Anonymous commented#23 worked for me!!
Comment #25
aharris6 CreditAttribution: aharris6 commented#23 worked for me as well
Comment #26
rv0 CreditAttribution: rv0 at Coworks.be commented#23 is working great
This line should be removed from patch though:
Comment #27
cafuego CreditAttribution: cafuego as a volunteer commentedI've just applied a pager patch from #2375235: Calendar block Next/Prev navigation broken which touches part of the code that's also in the patch on comment #23 in this issue.
Can you check whether the issue still exists on the latest 7.x-2.x module? If so, this patch will need a reroll to make it apply again.
Comment #28
coredumperror CreditAttribution: coredumperror commentedUpdating the latest dev release (2015-Dec-10) fixed this pager issue for me, without any patches from this thread.
Comment #29
BBCThis problem resurfaced for me again this year. The 2015-Dec-10 7.x-2.x-dev release works for me as well and the issues with ISO-8601 week numbers described in #16 seem to be resolved. Thanks!
Comment #30
Peter Arius CreditAttribution: Peter Arius as a volunteer commentedSorry, I can't confirm that this is fixed in latest dev.
date 7.x-2.9+5-dev (2015-Dez-10)
calendar 7.x-3.5
Steps to reproduce:
* show calendar month view, December 2015
* switch to week view (Week of Dec 28, 2015), OK
* next link goes to 2016-W01 (OK)
* click on next link -> URL is .../2016-W01 (OK), but still 2015-W53 is displayed (wrong)
When I enter any URL .../2016-Wnn, the view shows week nn-1. The previous link goes to 2016-W(nn-2) and the next link to 2016-Wnn, so the week view and pager is effectively unusable.
However, patch #2 from #2416421-2: Wrong week numbering for 2016 solves the issue for me.
Comment #31
StryKaizerHappy new year everybody who's just like me, visitting this issue ;)
Patch in #23 worked for me, might need a reroll though (manual apply fixxed the issue).
Comment #32
SeanA CreditAttribution: SeanA commentedComment #33
SeanA CreditAttribution: SeanA commentedPatch in #23 needs re-rolled to accommodate the partial fixes committed in #2372073: Undefined variable: granularity in date_views_plugin_pager->query() (line 285 of //modules/date/date_views/includes/date_views_plugin_pager.inc). and #2375235: Calendar block Next/Prev navigation broken.
Comment #34
SeanA CreditAttribution: SeanA commentedThis should fix all problems with the prev/next links on the month and week displays. Please test and verify.
Comment #35
dsoms CreditAttribution: dsoms commented#23 worked fine for me with Date 7.x-2.9
Thank you very much ;-)
Comment #36
Stephen Ollman#23 fixed my issue with not being able to access 'Next' week.
Comment #37
sobi3ch CreditAttribution: sobi3ch as a volunteer and at Bytech commented#34 works like a charm :)
Comment #39
SeanA CreditAttribution: SeanA commenteddanwonac gets credit for sorting it all out. =)
Comment #40
podarok#34 merged. Thanks.