Skip to content

[bug]: Reccurent Events do not work with local Calendar #682

@julien-celya

Description

@julien-celya

FreePBX Version

FreePBX 16

Issue Description

Hi,
Here is the configuration I used :

  • a local calendar that some users can access and modify
  • added a recurring event ( 8am to 5pm, recurring 4 times ) with a category
  • a calendar event group that match for previous category
  • a time condition that checks the calendar event group

The time condition does not match (at the very least during a recurring event)

Hunting down the bug, it appears to be in the Calendar module, either in IcalParser/IcalRangedParser.php or in the handling of recurring event for a local calendar.

In IcalParser/IcalRangedParser.php, getEventsNow([...]) expects $event['RECURRENCES'] to be timestamps when they are objects :

[...]
["RECURRENCES"]=>                
      array(4) {                       
        [0]=>                          
        object(DateTime)#55 (3) {      
          ["date"]=>                   
          string(26) "2025-04-22 12:30:00.000000"
          ["timezone_type"]=>          
          int(3)                       
          ["timezone"]=>               
          string(12) "Europe/Paris"    
        }
[...]

Working fix for the Calendar module :

diff --git a/IcalParser/IcalRangedParser.php b/IcalParser/IcalRangedParser.php
index 704d156..47b964b 100644
--- a/IcalParser/IcalRangedParser.php
+++ b/IcalParser/IcalRangedParser.php
@@ -366,7 +366,7 @@ class IcalRangedParser extends IcalParser
 					$eventDuration = $event['DTEND']->getTimestamp() - $event['DTSTART']->getTimestamp();
 
 					foreach ($recurrences as $recurrenceTimestamp) {
-						if ($now > $recurrenceTimestamp && $now < ($recurrenceTimestamp + $eventDuration)) {
+						if ($now > $recurrenceTimestamp->getTimestamp() && $now < ($recurrenceTimestamp->getTimestamp() + $eventDuration)) {
 							array_push($events, $event); //at least one recurrence is now, keep it
 							continue 2; //go to the next event
 						}

Regards,

Operating Environment

Debian 12
asterisk 20.11.1
calendar | 16.0.34
core | 16.0.68.30
framework | 16.0.40.11
timeconditions | 16.0.11

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions