File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed
Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 1010### Fixed
1111
1212- Added a workaround for a Carbon 3 bug that makes occursAt fail in some cases [ #164 ] ( https://github.com/rlanvin/php-rrule/issues/164 )
13+ - Fix RSet not de-duplicating when using array access [ #165 ] ( https://github.com/rlanvin/php-rrule/issues/165 )
1314
1415## [ 2.6.0] - 2025-04-25
1516
Original file line number Diff line number Diff line change @@ -600,14 +600,15 @@ public function count()
600600 #[\ReturnTypeWillChange]
601601 public function getIterator ()
602602 {
603- $ previous_occurrence = null ;
604603 $ total = 0 ;
605604
605+ $ occurrence = null ;
606606 foreach ($ this ->cache as $ occurrence ) {
607607 yield clone $ occurrence ; // since DateTime is not immutable, avoid any problem
608608
609609 $ total += 1 ;
610610 }
611+ $ previous_occurrence = $ occurrence ;
611612
612613 if ($ this ->rlist_heap === null ) {
613614 // rrules + rdate
Original file line number Diff line number Diff line change @@ -87,6 +87,36 @@ public function testCombineRRuleAndDate()
8787 $ this ->assertFalse ($ rset ->occursAt ('1997-09-03 09:00 ' ));
8888 }
8989
90+ /**
91+ * @see https://github.com/rlanvin/php-rrule/issues/165
92+ */
93+ public function testCombineRRuleAndRDateWithDuplicatesArrayAccess ()
94+ {
95+ $ rset = new RSet ();
96+ $ rset ->addRRule (array (
97+ 'FREQ ' => 'WEEKLY ' ,
98+ 'BYDAY ' => 'TU ' ,
99+ 'DTSTART ' => date_create ('2025-06-03 09:00 ' )
100+ ));
101+ $ rset ->addDate ('2025-06-03 09:00 ' );
102+ $ rset ->addDate ('2025-06-10 09:00 ' );
103+ $ rset ->addDate ('2025-06-11 09:00 ' );
104+
105+ $ occurences = [];
106+ for ($ i = 0 ; $ i < 5 ; $ i ++) {
107+ $ occurences [] = $ rset [$ i ];
108+ }
109+ $ expected = [
110+ date_create ('2025-06-03 09:00 ' ),
111+ date_create ('2025-06-10 09:00 ' ),
112+ date_create ('2025-06-11 09:00 ' ),
113+ date_create ('2025-06-17 09:00 ' ),
114+ date_create ('2025-06-24 09:00 ' )
115+ ];
116+
117+ $ this ->assertEquals ($ expected , $ occurences );
118+ }
119+
90120 public function testRemoveDateFromRSet ()
91121 {
92122 $ rset = new RSet ();
You can’t perform that action at this time.
0 commit comments