Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EventIterator returns wrong end endTime #534

Closed
floerke opened this issue May 17, 2021 · 5 comments
Closed

EventIterator returns wrong end endTime #534

floerke opened this issue May 17, 2021 · 5 comments

Comments

@floerke
Copy link
Contributor

floerke commented May 17, 2021

Hi,

the EventIterator returns a wrong endTime for

  • a recurring event
  • with an exception and a different endTime

Example:
Everyday from 9am-10am, except on 20210519 from 9am-12am

BEGIN:VCALENDAR
PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN
VERSION:2.0
BEGIN:VTIMEZONE
TZID:Europe/Berlin
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:CEST
DTSTART:19700329T020000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:19701025T030000
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
END:STANDARD
END:VTIMEZONE

BEGIN:VEVENT
CREATED:20210517T073701Z
LAST-MODIFIED:20210517T095958Z
DTSTAMP:20210517T095958Z
UID:e47c8ee2-5545-4c15-8fe5-7dd1960a4446
SUMMARY:9Uhr
RRULE:FREQ=DAILY
DTSTART;TZID=Europe/Berlin:20210517T090000
DTEND;TZID=Europe/Berlin:20210517T100000
TRANSP:OPAQUE
X-MOZ-GENERATION:1
END:VEVENT

BEGIN:VEVENT
CREATED:20210517T073809Z
LAST-MODIFIED:20210517T073833Z
DTSTAMP:20210517T073833Z
UID:e47c8ee2-5545-4c15-8fe5-7dd1960a4446
SUMMARY:9Uhr
RECURRENCE-ID;TZID=Europe/Berlin:20210519T090000
DTSTART;TZID=Europe/Berlin:20210519T090000
DTEND;TZID=Europe/Berlin:20210519T120000
TRANSP:OPAQUE
SEQUENCE:1
END:VEVENT
END:VCALENDAR

Results in:
Start 9am, Ends 10am on 20210519

I have noticed this because my thunderbird/lightning showing wrong freebusy-times in this case using nextcloud. Your FreeBusyGenerator.php is using the EventIterator to calculate the FreeBusy hours.

In the EventIterator you calculate the end-date by adding the (master-)eventDuration on the start-date:

   public function getDtEnd()
    {
        if (!$this->valid()) {
            return;
        }
        $end = clone $this->currentDate;

        return $end->modify('+'.$this->eventDuration.' seconds');
    }

The eventDuration is never changed within the next()-function. Therefore the end-date is wrong for exceptions in length.

@floerke
Copy link
Contributor Author

floerke commented May 17, 2021

Fast and Ugly:

    public function getDtEnd()
    {
        if (!$this->valid()) {
          return;
        }

        if ($this->currentOverriddenEvent) {
            return $this->currentOverriddenEvent->DTEND->getDateTime($this->timeZone);
        }
        else {
          $end = clone $this->currentDate;

          return $end->modify('+'.$this->eventDuration.' seconds');
       }
    }

But I am not so familiar with sabre-code...

@floerke
Copy link
Contributor Author

floerke commented Aug 3, 2021

Nobody interested in this fix?

@staabm
Copy link
Member

staabm commented Aug 3, 2021

feel free to provide a PR with the failing test-case and the fix.

we will see whether this changes causes regression for other test-cases then.

thank you.

floerke added a commit to floerke/vobject that referenced this issue Aug 4, 2021
floerke added a commit to floerke/vobject that referenced this issue Aug 4, 2021
floerke added a commit to floerke/vobject that referenced this issue Aug 4, 2021
floerke added a commit to floerke/vobject that referenced this issue Aug 4, 2021
@floerke
Copy link
Contributor Author

floerke commented Aug 4, 2021

Sorry for multiple commits. Fighting with CodeStyle :^)

phil-davis pushed a commit to floerke/vobject that referenced this issue Nov 14, 2021
phil-davis added a commit that referenced this issue Nov 14, 2021
EventIterator returns wrong endTime (#534)
@phil-davis
Copy link
Contributor

Fixed by #538

valentinbonneaud pushed a commit to ProtonMail/vobject that referenced this issue Dec 15, 2021
* fix  Bad file descriptor (7.4) (sabre-io#469)

* travis: allow failure for phpstan for now (sabre-io#470)

* travis: add php 7.4snapshot build (sabre-io#471)

* reduce phpstan level back to 0, as level 1 is failing right now (sabre-io#472)

* reduce phpstan level back to 0, as level 1 is failing right now

* travis: no longer allow failures for phpstan

* Fixed typo in vobject CLI help (sabre-io#477)

* Release 4.2.1 (sabre-io#479)

* Release 4.2.1

* Update CHANGELOG.md

* Prepare next iteration (sabre-io#480)

* Run phpstan on PHP >= 7.1 (sabre-io#483)

* Add TZ in iTip REPLY messages

* Added phpstan for tests folder (sabre-io#485)

* Add PHONE-NUMBER value type (used for TEL in vCard 3.0) (sabre-io#486)

Signed-off-by: Christian Kraus <hanzi@hanzi.cc>

* use latest phpstan 0.12.5 in CI

* Add PHPstorm .idea to .gitignore

* Fix various typos

* Release 4.2.2 (sabre-io#490)

* Release 4.2.2

* Update CHANGELOG.md

* Prepare next iteration

* Update dependencies and code style tools

* Remove unneeded 'bootstrap' line from phpstan.neon

* Apply php-cs-fixer code style changes

* run php-cs-fixer in CI

* php-cs-fixer must be at least 2.16.1 for PHP 7.4

* Use phpunit8 where possible

* Fixed phpstan level 1 errors

* Make sure there is no logic change

* Prevent setting foreach key beforehand

* Refactored fqcn strings to ::class to allow checking with phpstan (sabre-io#495)

* Release 4.3.0 (sabre-io#497)

* Update CHANGELOG.md

* Update Version.php

* Added phpstan to dev dependencies

* Reset bin-dir config

* Added convenient development commands

* Cleaned up .gitignore
These entries should be in the developer's global .gitignore

* cs-fixer: don't check only the lib folder

* Decoupled cs-fixer command from chosen tool

* Standardize CI

* Use phpunit 9 where possible

* Only upload coverage when it has been collected

* Replace assertRegExp with assertMatchesRegularExpression in unit test

* fix an incomplete phpdoc type annotation

* Release 4.3.1

* Adjust boolean vars in .travis.yml to prepare for PHP8.0

* Run unit tests on PHP8

* Fixup calendar parameter to Broker parseEvent

* Release 4.3.2

* Remove Pacific-New obsolete timezone

* Do composer remove --no-update in Travis

* Use min php-cs-fixer 2.16.7

* Release 4.3.3

* Add .gitattributes

* Explicitly select PHP 8.0 in CI

* Use latest php-cs-fixer 2.17.1

* Update windowszones timezone data to 2020-12-13

* Fix typos

* Reassign modified date in yearly rrule

* Add test

* Code style

* Add test for calendar expand

* adjust unit test settings for time limits

Some tests were testing a bug that caused an infinite loop.

Annotate those tests with large, small annotations.

Turn on enforceTimeLimit, failOnWarning and failOnRisky so that the
annotations are enforced when unit tests are run.

Add phpunit/php-invoker to the composer require-dev becaause this is
required to make the enforceTimeLimit setting effective.

* Release 4.3.4

* Make use of until parameter in nextMonthly function

* CS FIX

* CS FIX

* Fix breaking tests

* create testMonthlyByDayUntil

* create testMonthlyByDayUntilWithImpossibleNextOccurrence

* Fix setting properties with group assignment

* Unit test for adding properties with group for a VCard

* Adapt style

* Release 4.3.5

* tests: migrate from Travis to gh-actions

* Removed travis config

* Minor edit to README

* Run phpunit with coverage in CI

* Fix deprecated usages and return types on PHP 8.1

* sync ci.yml to match other repos

* Changes that should have happened for 4.3.6

* changelog and VERSION bump for 4.3.7

* EventIterator returns wrong endTime (sabre-io#534)

* Reordering of the attendees should not be a signitifcant change (sabre-io#540)

* Reordering of vevent should not be a significant change (sabre-io#542)

* Prepare release 4.3.8

* Allow easier extension of the timezone guessing

This will ease customization of timezone-guessing as it is now gets easier
to extend that process with own implementations (as long as they
implement the appropriate interface)

This is espechially necessary when wanting to actually guess a timezone
via the rules defined in the VTIMEZONE-entry (which is currently not
done)

* testEmptyTimeZone

* Changelog for 4.4.0

* Fix Changelog

* Merge github actions

Co-authored-by: Remi Collet <remi@remirepo.net>
Co-authored-by: Markus Staab <maggus.staab@googlemail.com>
Co-authored-by: Dominik <dominik@tobschall.de>
Co-authored-by: Jeroen van Oort <jvanoort@simplexis.nl>
Co-authored-by: Renaud BOYER <rboyer@linagora.com>
Co-authored-by: Christian Kraus <github@hanzi.cc>
Co-authored-by: Thomas Müller <thomas.mueller@tmit.eu>
Co-authored-by: Phil Davis <phil@jankaritech.com>
Co-authored-by: Michael Stilkerich <ms@mike2k.de>
Co-authored-by: Stéphane <demonchaux.stephane@gmail.com>
Co-authored-by: Allon Moritz <allon.moritz@digital-peak.com>
Co-authored-by: Jair Cueva Junior <junior@dinhost.com.br>
Co-authored-by: Parajuli Kiran <kiranparajuli589@gmail.com>
Co-authored-by: Cédric Anne <cedric.anne@gmail.com>
Co-authored-by: Holger Floerke <floerke@doctronic.de>
Co-authored-by: Andreas Heigl <andreas@heigl.org>
valentinbonneaud added a commit to ProtonMail/vobject that referenced this issue Dec 15, 2021
* fix  Bad file descriptor (7.4) (sabre-io#469)

* travis: allow failure for phpstan for now (sabre-io#470)

* travis: add php 7.4snapshot build (sabre-io#471)

* reduce phpstan level back to 0, as level 1 is failing right now (sabre-io#472)

* reduce phpstan level back to 0, as level 1 is failing right now

* travis: no longer allow failures for phpstan

* Fixed typo in vobject CLI help (sabre-io#477)

* Release 4.2.1 (sabre-io#479)

* Release 4.2.1

* Update CHANGELOG.md

* Prepare next iteration (sabre-io#480)

* Run phpstan on PHP >= 7.1 (sabre-io#483)

* Add TZ in iTip REPLY messages

* Added phpstan for tests folder (sabre-io#485)

* Add PHONE-NUMBER value type (used for TEL in vCard 3.0) (sabre-io#486)

Signed-off-by: Christian Kraus <hanzi@hanzi.cc>

* use latest phpstan 0.12.5 in CI

* Add PHPstorm .idea to .gitignore

* Fix various typos

* Release 4.2.2 (sabre-io#490)

* Release 4.2.2

* Update CHANGELOG.md

* Prepare next iteration

* Update dependencies and code style tools

* Remove unneeded 'bootstrap' line from phpstan.neon

* Apply php-cs-fixer code style changes

* run php-cs-fixer in CI

* php-cs-fixer must be at least 2.16.1 for PHP 7.4

* Use phpunit8 where possible

* Fixed phpstan level 1 errors

* Make sure there is no logic change

* Prevent setting foreach key beforehand

* Refactored fqcn strings to ::class to allow checking with phpstan (sabre-io#495)

* Release 4.3.0 (sabre-io#497)

* Update CHANGELOG.md

* Update Version.php

* Added phpstan to dev dependencies

* Reset bin-dir config

* Added convenient development commands

* Cleaned up .gitignore
These entries should be in the developer's global .gitignore

* cs-fixer: don't check only the lib folder

* Decoupled cs-fixer command from chosen tool

* Standardize CI

* Use phpunit 9 where possible

* Only upload coverage when it has been collected

* Replace assertRegExp with assertMatchesRegularExpression in unit test

* fix an incomplete phpdoc type annotation

* Release 4.3.1

* Adjust boolean vars in .travis.yml to prepare for PHP8.0

* Run unit tests on PHP8

* Fixup calendar parameter to Broker parseEvent

* Release 4.3.2

* Remove Pacific-New obsolete timezone

* Do composer remove --no-update in Travis

* Use min php-cs-fixer 2.16.7

* Release 4.3.3

* Add .gitattributes

* Explicitly select PHP 8.0 in CI

* Use latest php-cs-fixer 2.17.1

* Update windowszones timezone data to 2020-12-13

* Fix typos

* Reassign modified date in yearly rrule

* Add test

* Code style

* Add test for calendar expand

* adjust unit test settings for time limits

Some tests were testing a bug that caused an infinite loop.

Annotate those tests with large, small annotations.

Turn on enforceTimeLimit, failOnWarning and failOnRisky so that the
annotations are enforced when unit tests are run.

Add phpunit/php-invoker to the composer require-dev becaause this is
required to make the enforceTimeLimit setting effective.

* Release 4.3.4

* Make use of until parameter in nextMonthly function

* CS FIX

* CS FIX

* Fix breaking tests

* create testMonthlyByDayUntil

* create testMonthlyByDayUntilWithImpossibleNextOccurrence

* Fix setting properties with group assignment

* Unit test for adding properties with group for a VCard

* Adapt style

* Release 4.3.5

* tests: migrate from Travis to gh-actions

* Removed travis config

* Minor edit to README

* Run phpunit with coverage in CI

* Fix deprecated usages and return types on PHP 8.1

* sync ci.yml to match other repos

* Changes that should have happened for 4.3.6

* changelog and VERSION bump for 4.3.7

* EventIterator returns wrong endTime (sabre-io#534)

* Reordering of the attendees should not be a signitifcant change (sabre-io#540)

* Reordering of vevent should not be a significant change (sabre-io#542)

* Prepare release 4.3.8

* Allow easier extension of the timezone guessing

This will ease customization of timezone-guessing as it is now gets easier
to extend that process with own implementations (as long as they
implement the appropriate interface)

This is espechially necessary when wanting to actually guess a timezone
via the rules defined in the VTIMEZONE-entry (which is currently not
done)

* testEmptyTimeZone

* Changelog for 4.4.0

* Fix Iterator method signatures

This avoids warnings under PHP>=8.1
Real return types should be added before PHP 9

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>

* Avoid passing null as separator for implode

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>

* Prepare release 4.4.1

* Rebase fix

* Add PHP8.1 CI

* Remove PHPUnit update

* Fix PHP8.1 tests

Co-authored-by: Remi Collet <remi@remirepo.net>
Co-authored-by: Markus Staab <maggus.staab@googlemail.com>
Co-authored-by: Dominik <dominik@tobschall.de>
Co-authored-by: Jeroen van Oort <jvanoort@simplexis.nl>
Co-authored-by: Renaud BOYER <rboyer@linagora.com>
Co-authored-by: Christian Kraus <github@hanzi.cc>
Co-authored-by: Thomas Müller <thomas.mueller@tmit.eu>
Co-authored-by: Phil Davis <phil@jankaritech.com>
Co-authored-by: Michael Stilkerich <ms@mike2k.de>
Co-authored-by: Stéphane <demonchaux.stephane@gmail.com>
Co-authored-by: Allon Moritz <allon.moritz@digital-peak.com>
Co-authored-by: Jair Cueva Junior <junior@dinhost.com.br>
Co-authored-by: Parajuli Kiran <kiranparajuli589@gmail.com>
Co-authored-by: Cédric Anne <cedric.anne@gmail.com>
Co-authored-by: Holger Floerke <floerke@doctronic.de>
Co-authored-by: Andreas Heigl <andreas@heigl.org>
Co-authored-by: Côme Chilliet <come.chilliet@nextcloud.com>
valentinbonneaud pushed a commit to ProtonMail/vobject that referenced this issue May 26, 2022
* fix  Bad file descriptor (7.4) (sabre-io#469)

* travis: allow failure for phpstan for now (sabre-io#470)

* travis: add php 7.4snapshot build (sabre-io#471)

* reduce phpstan level back to 0, as level 1 is failing right now (sabre-io#472)

* reduce phpstan level back to 0, as level 1 is failing right now

* travis: no longer allow failures for phpstan

* Fixed typo in vobject CLI help (sabre-io#477)

* Release 4.2.1 (sabre-io#479)

* Release 4.2.1

* Update CHANGELOG.md

* Prepare next iteration (sabre-io#480)

* Run phpstan on PHP >= 7.1 (sabre-io#483)

* Add TZ in iTip REPLY messages

* Added phpstan for tests folder (sabre-io#485)

* Add PHONE-NUMBER value type (used for TEL in vCard 3.0) (sabre-io#486)

Signed-off-by: Christian Kraus <hanzi@hanzi.cc>

* use latest phpstan 0.12.5 in CI

* Add PHPstorm .idea to .gitignore

* Fix various typos

* Release 4.2.2 (sabre-io#490)

* Release 4.2.2

* Update CHANGELOG.md

* Prepare next iteration

* Update dependencies and code style tools

* Remove unneeded 'bootstrap' line from phpstan.neon

* Apply php-cs-fixer code style changes

* run php-cs-fixer in CI

* php-cs-fixer must be at least 2.16.1 for PHP 7.4

* Use phpunit8 where possible

* Fixed phpstan level 1 errors

* Make sure there is no logic change

* Prevent setting foreach key beforehand

* Refactored fqcn strings to ::class to allow checking with phpstan (sabre-io#495)

* Release 4.3.0 (sabre-io#497)

* Update CHANGELOG.md

* Update Version.php

* Added phpstan to dev dependencies

* Reset bin-dir config

* Added convenient development commands

* Cleaned up .gitignore
These entries should be in the developer's global .gitignore

* cs-fixer: don't check only the lib folder

* Decoupled cs-fixer command from chosen tool

* Standardize CI

* Use phpunit 9 where possible

* Only upload coverage when it has been collected

* Replace assertRegExp with assertMatchesRegularExpression in unit test

* fix an incomplete phpdoc type annotation

* Release 4.3.1

* Adjust boolean vars in .travis.yml to prepare for PHP8.0

* Run unit tests on PHP8

* Fixup calendar parameter to Broker parseEvent

* Release 4.3.2

* Remove Pacific-New obsolete timezone

* Do composer remove --no-update in Travis

* Use min php-cs-fixer 2.16.7

* Release 4.3.3

* Add .gitattributes

* Explicitly select PHP 8.0 in CI

* Use latest php-cs-fixer 2.17.1

* Update windowszones timezone data to 2020-12-13

* Fix typos

* Reassign modified date in yearly rrule

* Add test

* Code style

* Add test for calendar expand

* adjust unit test settings for time limits

Some tests were testing a bug that caused an infinite loop.

Annotate those tests with large, small annotations.

Turn on enforceTimeLimit, failOnWarning and failOnRisky so that the
annotations are enforced when unit tests are run.

Add phpunit/php-invoker to the composer require-dev becaause this is
required to make the enforceTimeLimit setting effective.

* Release 4.3.4

* Make use of until parameter in nextMonthly function

* CS FIX

* CS FIX

* Fix breaking tests

* create testMonthlyByDayUntil

* create testMonthlyByDayUntilWithImpossibleNextOccurrence

* Fix setting properties with group assignment

* Unit test for adding properties with group for a VCard

* Adapt style

* Release 4.3.5

* tests: migrate from Travis to gh-actions

* Removed travis config

* Minor edit to README

* Run phpunit with coverage in CI

* Fix deprecated usages and return types on PHP 8.1

* sync ci.yml to match other repos

* Changes that should have happened for 4.3.6

* changelog and VERSION bump for 4.3.7

* EventIterator returns wrong endTime (sabre-io#534)

* Reordering of the attendees should not be a signitifcant change (sabre-io#540)

* Reordering of vevent should not be a significant change (sabre-io#542)

* Prepare release 4.3.8

* Allow easier extension of the timezone guessing

This will ease customization of timezone-guessing as it is now gets easier
to extend that process with own implementations (as long as they
implement the appropriate interface)

This is espechially necessary when wanting to actually guess a timezone
via the rules defined in the VTIMEZONE-entry (which is currently not
done)

* testEmptyTimeZone

* Changelog for 4.4.0

* Fix Iterator method signatures

This avoids warnings under PHP>=8.1
Real return types should be added before PHP 9

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>

* Avoid passing null as separator for implode

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>

* Prepare release 4.4.1

* Component/select: Before uppercasing $child->group, make sure it isn't null

Signed-off-by: Gergely Nagy <me@gergo.csillger.hu>

* fix php 8.1 null string deprecation in built-in functions

* drop duplicated workflow config

Co-authored-by: Remi Collet <remi@remirepo.net>
Co-authored-by: Markus Staab <maggus.staab@googlemail.com>
Co-authored-by: Dominik <dominik@tobschall.de>
Co-authored-by: Jeroen van Oort <jvanoort@simplexis.nl>
Co-authored-by: Renaud BOYER <rboyer@linagora.com>
Co-authored-by: Christian Kraus <github@hanzi.cc>
Co-authored-by: Thomas Müller <thomas.mueller@tmit.eu>
Co-authored-by: Phil Davis <phil@jankaritech.com>
Co-authored-by: Michael Stilkerich <ms@mike2k.de>
Co-authored-by: Stéphane <demonchaux.stephane@gmail.com>
Co-authored-by: Allon Moritz <allon.moritz@digital-peak.com>
Co-authored-by: Jair Cueva Junior <junior@dinhost.com.br>
Co-authored-by: Parajuli Kiran <kiranparajuli589@gmail.com>
Co-authored-by: Cédric Anne <cedric.anne@gmail.com>
Co-authored-by: Holger Floerke <floerke@doctronic.de>
Co-authored-by: Andreas Heigl <andreas@heigl.org>
Co-authored-by: Côme Chilliet <come.chilliet@nextcloud.com>
Co-authored-by: Gergely Nagy <me@gergo.csillger.hu>
Co-authored-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
Co-authored-by: Christopher Szu <christopher.szu@proton.ch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants