sabre-io / Baikal

Baïkal is a Calendar+Contacts server
https://sabre.io/baikal/
GNU General Public License v3.0
2.42k stars 281 forks source link

Baikal sets `cal:calendar-timezone` to a timezone string instead of a VTIMEZONE when creating a new calendar via the web UI #1241

Open apollo-sturdy opened 4 months ago

apollo-sturdy commented 4 months ago

Baikal version: 0.9.4

Expected behaviour:

Baikal should set the field to a correct iCalendar object with a VTIMEZONE. This causes the following bug: https://github.com/sabre-io/Baikal/issues/1085 which causes integrations to fail with Cal.com and HomeAssistant.

Current behaviour:

Baikal sets the field to the timzone string from the settings.

Steps to reproduce:

  1. Install Baikal
  2. Create new calendar
  3. Check cal:calendar-timezone field
apollo-sturdy commented 4 months ago

For any readers here, as a temporary fix you can re-create your calendars in iCal (MacOS Calendar app): https://github.com/sabre-io/Baikal/issues/1085#issuecomment-1961249347

nepomuc commented 4 months ago

Please fix this. I don't have iCal. :/

fr567 commented 1 month ago

I'm also very intererested in getting a solution for the manual installation on a webhosting service.

fr567 commented 1 month ago

I'm also very intererested in getting a solution for the manual installation on a webhosting service.

I replaced the baikal\vendor\sabre\dav\lib\CalDAV\Plugin.php from the release baikal-0.9.5.zip with the the baikal-docker-hass/files/Plugin.php and now it works also with Home Assistant.

pegelow commented 2 weeks ago

You ca solve the problem like this:

edit the baikal-file: /vendor/sabre/dav/lib/CalDAV/Plugin.php

        if ($report->expand) {
            // We're expanding, and for that we need to figure out the
            // calendar's timezone.
            $tzProp = '{'.self::NS_CALDAV.'}calendar-timezone';
            $tzResult = $this->server->getProperties($path, [$tzProp]);
            if (isset($tzResult[$tzProp])) {
                // This property contains a VCALENDAR with a single
                // VTIMEZONE.
                $vtimezoneObj = VObject\Reader::read($tzResult[$tzProp]);
                $calendarTimeZone = $vtimezoneObj->VTIMEZONE->getTimeZone();

                // Destroy circular references so PHP will garbage collect the
                // object.
                $vtimezoneObj->destroy();
            } else {
                // Defaulting to UTC.
                $calendarTimeZone = new DateTimeZone('UTC');
            }
        }

=>

        if ($report->expand) {
            // We're expanding, and for that we need to figure out the
            // calendar's timezone.
            $tzProp = '{'.self::NS_CALDAV.'}calendar-timezone';
            $tzResult = $this->server->getProperties($path, [$tzProp]);
            if (isset($tzResult[$tzProp])) {
                $calendarTimeZone = new DateTimeZone($tzResult[$tzProp]);
            } else {
                // Defaulting to UTC.
                $calendarTimeZone = new DateTimeZone('UTC');
            }
        }
pegelow commented 2 weeks ago

patch patch.txt

Tntdruid commented 2 weeks ago

do a PR for that.