Skip to content

Commit 20d6c73

Browse files
authored
Merge pull request #529 from laoneo/patch-1
Reassign modified date in yearly rrule
2 parents da42738 + b571095 commit 20d6c73

File tree

5 files changed

+52
-1
lines changed

5 files changed

+52
-1
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"require-dev" : {
4040
"friendsofphp/php-cs-fixer": "~2.17.1",
4141
"phpunit/phpunit" : "^7.5 || ^8.5 || ^9.0",
42+
"phpunit/php-invoker" : "^2.0 || ^3.1",
4243
"phpstan/phpstan": "^0.12"
4344
},
4445
"suggest" : {

lib/Recur/RRuleIterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ protected function nextYearly()
536536
foreach ($this->byWeekNo as $byWeekNo) {
537537
foreach ($dayOffsets as $dayOffset) {
538538
$date = clone $this->currentDate;
539-
$date->setISODate($currentYear, $byWeekNo, $dayOffset);
539+
$date = $date->setISODate($currentYear, $byWeekNo, $dayOffset);
540540

541541
if ($date > $this->currentDate) {
542542
$checkDates[] = $date;

tests/VObject/Component/VCalendarTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,33 @@ public function testBrokenEventExpand()
350350
);
351351
}
352352

353+
/**
354+
* This test used to induce an infinite loop.
355+
* The "medium" annotation means that phpunit will fail the
356+
* test if it takes longer than a default of 10 seconds.
357+
*
358+
* @medium
359+
*/
360+
public function testEventExpandYearly()
361+
{
362+
$input = 'BEGIN:VCALENDAR
363+
BEGIN:VEVENT
364+
UID:1a093f1012086078fdd3d9df5ff4d7d0
365+
DTSTART;TZID=UTC:20210203T130000
366+
DTEND;TZID=UTC:20210203T140000
367+
RRULE:FREQ=YEARLY;COUNT=7;WKST=MO;BYDAY=MO;BYWEEKNO=13,15,50
368+
END:VEVENT
369+
END:VCALENDAR
370+
';
371+
$vcal = VObject\Reader::read($input);
372+
$events = $vcal->expand(
373+
new \DateTime('2021-01-01'),
374+
new \DateTime('2023-01-01')
375+
);
376+
377+
$this->assertCount(7, $events->VEVENT);
378+
}
379+
353380
public function testGetDocumentType()
354381
{
355382
$vcard = new VCalendar();

tests/VObject/Recur/RRuleIteratorTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,19 @@ public function testYearlyByYearDayInvalid0()
591591
);
592592
}
593593

594+
public function testYearlyByDayByWeekNo()
595+
{
596+
$this->parse(
597+
'FREQ=YEARLY;COUNT=3;BYDAY=MO;BYWEEKNO=13,15,50',
598+
'2021-01-01 00:00:00',
599+
[
600+
'2021-01-01 00:00:00',
601+
'2021-03-29 00:00:00',
602+
'2021-04-12 00:00:00',
603+
]
604+
);
605+
}
606+
594607
public function testFastForward()
595608
{
596609
// The idea is that we're fast-forwarding too far in the future, so
@@ -879,6 +892,13 @@ public function testMinusFifthThursday()
879892
);
880893
}
881894

895+
/**
896+
* This test can take some seconds to complete.
897+
* The "large" annotation means phpunit will let it run for
898+
* up to 60 seconds by default.
899+
*
900+
* @large
901+
*/
882902
public function testNeverEnding()
883903
{
884904
$this->parse(

tests/phpunit.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
convertWarningsToExceptions="true"
77
beStrictAboutTestsThatDoNotTestAnything="true"
88
beStrictAboutOutputDuringTests="true"
9+
failOnRisky="true"
10+
failOnWarning="true"
11+
enforceTimeLimit="true"
912
>
1013
<testsuites>
1114
<testsuite name="Sabre\VObject">

0 commit comments

Comments
 (0)