Updated: Comment #1
Problem/Motivation
This is primarily an issue when importing Calendar views. If you export a calendar view the style option groupby_times
is not normally exported, unless the database value is overriding the default value defined in the calendar style plugin. When the view is subsequently imported (often via a Feature) the groupby_times
option is not initially stored in the database. The existing calendar code attempts to use the database value for groupby_times
, which then triggers error messages such as:
For a day view:
Notice: Undefined index: groupby_times in template_preprocess_calendar_day() (line 267 of /foo/sites/all/modules/calendar/theme/theme.inc).
Notice: Undefined index: groupby_times in template_preprocess_calendar_day() (line 271 of /foo/sites/all/modules/calendar/theme/theme.inc).
For a week view:
Notice: Undefined index: groupby_times in template_preprocess_calendar_week() (line 480 of /foo/sites/all/modules/calendar/theme/theme.inc).
Notice: Undefined index: groupby_times in template_preprocess_calendar_week() (line 484 of /foo/sites/all/modules/calendar/theme/theme.inc).
Proposed resolution
There are have been various resolutions proposed to address this issue. For those without the permissions or knowledge to apply a patch you can force the groupby_times
option to be stored in the database by editing the view and the day and week display and saving without changing any of the settings (see these instructions). An alternative is to edit the exported view configuration and and manually insert the option. However, the ideal resolution is to fix the code and this was discussed in #1397986: Errors at the day View: Undefined index: groupby_times in template_preprocess_calendar_day()...
Remaining tasks
Review patch below.
User interface changes
None.
API changes
None.
Comment | File | Size | Author |
---|---|---|---|
#18 | calendar-2160183-18.patch | 1.51 KB | rudiedirkx |
Comments
Comment #1
eft CreditAttribution: eft commentedThe attached patch attempts to resolve this issue for new and existing sites. Many thanks to FatGuyLaughing, jbylsma, dhalbert and KarenS for their work to date on this issue.
Comment #2
eft CreditAttribution: eft commentedComment #3
PascalAnimateur CreditAttribution: PascalAnimateur commentedThe patch works perfectly on my setup. You get my vote for a commit!
Comment #4
silurius CreditAttribution: silurius commentedEdit: Oops, wrong issue, nothing to see here...
Comment #5
guillaumev CreditAttribution: guillaumev commentedRelated issue: https://www.drupal.org/node/1895778.
In my case, this patch fixed both the user notice message AND the display of overlapping events in the week and day view... RTBC ?
Comment #6
miromarchi CreditAttribution: miromarchi commented+1 for Patch in #1, worked correctly! Thanks
Comment #7
Nemanja CreditAttribution: Nemanja commentedPatch works for me +1
Comment #8
milovan CreditAttribution: milovan commentedPatch works here as well, thanks. Will you include it in next release, please?
Comment #9
ladybug_3777 CreditAttribution: ladybug_3777 commentedAgreed, this patch works! Another vote to include it in the next release please!
Comment #10
dekisha CreditAttribution: dekisha commentedPatch worked for me also +1
Comment #11
michielkenis CreditAttribution: michielkenis commentedPatch tested and confirmed :)
Comment #12
lias CreditAttribution: lias commentedThis patch works for me as well. Will it be committed?
Comment #13
ademarco CreditAttribution: ademarco at Nuvole commentedWorks for me too.
Comment #14
KevinVb CreditAttribution: KevinVb commentedThis patch worked for me too. Please include it in a new release.
Comment #15
britter CreditAttribution: britter commentedSorry, I was having issues with multi-day entires extending too far in the view (check the screen shot) so I've devised a similar patch which works, but not as pretty :(
Comment #16
ron_s CreditAttribution: ron_s commented@eft, one minor issue with patch #1. We should fix the last two modified lines of the patch to have the correct Drupal format. Spaces are missing between the conditional and the bracket.
For example, this...
...should become this:
Comment #17
rudiedirkx CreditAttribution: rudiedirkx commentedThe option value still exists in the plugin handler, so check that. Checking for
isset()
is weird, because the plugin clearly defines the option. This fix is purely to avoid the Notice, not to fix the problem.Comment #18
rudiedirkx CreditAttribution: rudiedirkx commentedThis patch uses the plugin's settings, stored in the plugin handler object, where they always exist, because Views adds defaults if they're not in the export.
etc
Comment #19
jrearick#18 works for me. Avoiding the isset() if it's always defined in $view->style_plugin->options ['groupby_times'] seems like a good way to go. However, there is still no space before the { in the last two modified if/elsif as mentioned in #16
Comment #20
rudiedirkx CreditAttribution: rudiedirkx commentedThe maintainer can add that space if they want, when they add this. Thank you for not Needs work'ing it for a missing space =)
Comment #21
klidifia CreditAttribution: klidifia commentedConfirming that #18 works.
So the notices that are appearing actually seem to relate to a bug as well. I haven't looked into it too much but I got 4x these notices when looking at a day that had two events in overlapping times.
I noticed that without the patch applied and the PHP notices showing - that the events were not actually displayed correctly on the page - it was only showing one event and it did not span the correct time.
After applying this patch I can see both events side by side with the correct duration!
Comment #22
Jonathan Young CreditAttribution: Jonathan Young as a volunteer commentedI did a fresh install and ended up with the same issue and #18 solved my problem too
Comment #23
ladybug_3777 CreditAttribution: ladybug_3777 commentedI've removed patch #1 in favor of #18 and it is running smoothly so far!
Comment #24
jomarocas CreditAttribution: jomarocas as a volunteer commentedconfirming that working the patch #18 please post in the next update of calendar
Comment #25
fizk CreditAttribution: fizk commentedShould still be RTBC.
Comment #26
izus CreditAttribution: izus commentedWill there be a release with this patch in soon please ? we need a release, event alpha or beta one :)
Comment #27
jomarocas CreditAttribution: jomarocas as a volunteer commentedHi tested and for me working good in many projects this is patch to be ported
Comment #28
daften CreditAttribution: daften at District09 commentedThis should be RTBC @jomarocas, please read the issue status manual: https://www.drupal.org/node/156119 !!!
Comment #29
kobee CreditAttribution: kobee as a volunteer commentedOK for me with patch #18. Thanks @rudiedirkx
But one year after the patch, it still not committed to the dev branch?
The calendar module didn't have been updated since 2014 for the 7.x, so apparently it's not maintained anymore..
Comment #30
pcambra+1 to RTBC
Comment #32
fizk CreditAttribution: fizk commentedAll good things come to those who wait for far too long. Sorry for the delay :-/
Comment #34
kingandy CreditAttribution: kingandy commentedLooking forward to a stable release with this in
Comment #35
wylbur CreditAttribution: wylbur commentedComment #36
apadernoComment #37
apaderno