Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Eventlist: Option "shortened view" not activated #8786

Closed
arno1979 opened this issue Sep 21, 2017 · 1 comment
Closed

Eventlist: Option "shortened view" not activated #8786

arno1979 opened this issue Sep 21, 2017 · 1 comment
Assignees
Labels
Milestone

Comments

@arno1979
Copy link

arno1979 commented Sep 21, 2017

In addition to the problems described in #8782 I noticed multiple erroneous results with regards to the option set in the select menu "cal_format" of the eventlist module.
Because I believe that these errors come from a different source than the ones described in #8782 I decided to open a separate ticket.

Steps to reproduce:

  • An eventlist module configured to show only upcoming events.
  • Option "shortened view" NOT activated.
  • A multi-day event that begins in the past (e.g. 2017-09-01) and reaches into the future (e.g. 2017-10-22) and spans across more than one month.
  • Option value for "cal_format" set to either show upcoming events from the current or the next month.

"cal_format" set to show upcoming event from the current month:
Result: Today (2017-09-21) the eventlist shows single events from 2017-09-01 to 2017-10-01. Notice that one extra day from October is shown, which should not happen.

Expected result: Only events from 2017-09-21 to 2017-09-30 are shown.

"cal_format" set to show upcoming event from the next month:
Result: Today (2017-09-21) the eventlist shows single events from 2017-09-01 to 2017-10-31.

Expected result: Only events from 2017-10-01 to 2017-10-31 are shown.
Notice that in this case no overlap with November occur.

I think this has something to do with the different number of days in Septemner and October: September has 30 days - the error occurs, October has 31 days - no error occurs. Could it be that Contao always assumes months to have 31 days?
I tested this theory with another set of dates: 2018-01-01 to 2018-03-04 and then modified the server clock to simulate a current date of 2018-01-01.
When I set the eventlist to show upcoming events only for the next month the overlap is even stronger: the list then shows dates up to 2018-03-03, obviously because February only has 28 days.

As a sidenote: similar errors occur when setting "cal_format" to show only past events from the current month for example. In that case I would expect to see dates listed from 2017-09-01 up to and including 2017-09-20 (my test dates have no start or end times set).
Instead I get dates shown up to and including 2017-09-22.
I won't go into further details, because I suspect all this to be related.

Of course I dug a little into this trying to figure out where the error could come from.
I found this for loop in Events.php (function addEvent, rows 371 - 385) that takes care of generating single events from a multi-day event:

// Multi-day event
for ($i=1; $i<=$span && $intDate<=$intLimit; $i++)
{
    // Only show first occurrence
    if ($this->cal_noSpan)
    {
        break;
    }

    $intDate = strtotime('+ 1 day', $intDate);
    $intNextKey = date('Ymd', $intDate);

    $this->arrEvents[$intNextKey][$intDate][] = $arrEvent;
}

Moving the line $this->arrEvents[$intNextKey][$intDate][] = $arrEvent; above the two lines that modify the values of $intDate and $intNextKey changes the behavior but does not fix the problem, it just reverts it: with the dates from my example September dates are then shown with no overlap to October but October dates are then missing one day.
But maybe the for loop has to be modified to correctly add events to arrEvents based the number of days the affected month actually has (28/29, 30 or 31).

This applies to both Contao 3.x.x and 4.x.x

@arno1979 arno1979 changed the title Eventlist: Option "shortened view" not activated – Eventlist: Option "shortened view" not activated – problems with "cal_format" set to show upcoming events for current or next month Sep 21, 2017
@leofeyer leofeyer changed the title Eventlist: Option "shortened view" not activated – problems with "cal_format" set to show upcoming events for current or next month Eventlist: Option "shortened view" not activated Sep 21, 2017
@leofeyer leofeyer added this to the 3.5.29 milestone Sep 26, 2017
@leofeyer leofeyer self-assigned this Sep 26, 2017
@leofeyer
Copy link
Member

Also fixed in 03d2a8b.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants