nextcloud / server

☁️ Nextcloud server, a safe home for all your data
https://nextcloud.com
GNU Affero General Public License v3.0
27.37k stars 4.06k forks source link

[Bug]: DateTimeZone::__construct(): Unknown or bad timezone (W. Europe Standard Time) #48079

Open antondollmaier opened 1 month ago

antondollmaier commented 1 month ago

⚠️ This issue respects the following points: ⚠️

Bug description

When creating a new calendar meeting via eMClient on Windows, the server rejects the creation of the calendar event due to "unknown or bad timezone".

The client uses Windows 11. The timezone is configured per Windows default (UTC+01, Berlin, with daylight savings enabled).

The creation of appointments did work previously, so the issue was introduced either with NextCloud 30 (updated today) or previously, but not today, due to an updated emClient 10.

Steps to reproduce

  1. configure emClient on windows to access the calendar in NextCloud.
  2. create a new event: schedule appointment with 3rd party. Don't specify the timezone explicitly, but use the defaults
  3. The creation of the event fails with an Internal Server Error.

Expected behavior

The event is created, even though the Windows timezone specified in the request is unknown to NextCloud/Linux.

Nextcloud Server version

30

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.2

Web server

Apache (supported)

Database engine version

MariaDB

Is this bug present after an update or on a fresh install?

Upgraded to a MAJOR version (ex. 28 to 29)

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?

Configuration report

{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "cloud.aditsystems.de"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "30.0.0.14",
        "overwrite.cli.url": "https:\/\/cloud.aditsystems.de",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "mail_sendmailmode": "smtp",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "587",
        "mail_smtpauth": 1,
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "default_phone_region": "DE",
        "htaccess.RewriteBase": "\/",
        "forcessl": true,
        "trashbin_retention_obligation": "auto",
        "allow_user_to_change_display_name": false,
        "lost_password_link": "disabled",
        "oidc_login_provider_url": "https:\/\/sso.a1a-server.de\/realms\/ADIT_Intern\/",
        "oidc_login_client_id": "nextcloud",
        "oidc_login_client_secret": "xxxx",
        "oidc_login_auto_redirect": true,
        "oidc_login_logout_url": "https:\/\/cloud.aditsystems.de\/apps\/oidc_login\/oidc",
        "oidc_login_end_session_redirect": true,
        "oidc_login_redir_fallback": false,
        "oidc_login_attributes": {
            "id": "preferred_username",
            "mail": "email"
        },
        "overwriteprotocol": "https",
        "oidc_login_default_quota": 26843545600,
        "oidc_login_button_text": "Log in with KeyCloak SSO",
        "oidc_login_hide_password_form": false,
        "oidc_login_use_id_token": false,
        "oidc_login_default_group": "",
        "oidc_login_use_external_storage": false,
        "oidc_login_scope": "openid profile",
        "oidc_login_proxy_ldap": false,
        "oidc_login_disable_registration": false,
        "oidc_login_alt_login_page": "assets\/login.php",
        "oidc_login_tls_verify": true,
        "oidc_create_groups": false,
        "oidc_login_webdav_enabled": false,
        "oidc_login_password_authentication": false,
        "oidc_login_public_key_caching_time": 86400,
        "oidc_login_min_time_between_jwks_requests": 10,
        "oidc_login_well_known_caching_time": 86400,
        "oidc_login_update_avatar": false,
        "oidc_login_skip_proxy": false,
        "oidc_login_code_challenge_method": "",
        "maintenance": false,
        "app_install_overwrite": [
            "bookmarks_fulltextsearch",
            "oidc_login",
            "groupfolders",
            "fulltextsearch_elasticsearch",
            "fulltextsearch",
            "files_fulltextsearch"
        ],
        "theme": "",
        "loglevel": 0,
        "maintenance_window_start": 1,
        "default_timezone": "Europe\/Berlin"
    }
}

List of activated Apps

Enabled:
  - activity: 3.0.0
  - admin_audit: 1.20.0
  - announcementcenter: 7.0.0
  - bookmarks: 15.0.1
  - bruteforcesettings: 3.0.0
  - calendar: 5.0.0
  - circles: 30.0.0-dev
  - cloud_federation_api: 1.13.0
  - comments: 1.20.1
  - contacts: 6.1.0
  - contactsinteraction: 1.11.0
  - dashboard: 7.10.0
  - dav: 1.31.1
  - deck: 1.14.0
  - federatedfilesharing: 1.20.0
  - federation: 1.20.0
  - files: 2.2.0
  - files_downloadlimit: 3.0.0
  - files_fulltextsearch: 30.0.0
  - files_pdfviewer: 3.0.0
  - files_reminders: 1.3.0
  - files_retention: 1.19.0
  - files_sharing: 1.22.0
  - files_trashbin: 1.20.1
  - files_versions: 1.23.0
  - firstrunwizard: 3.0.0
  - fulltextsearch: 30.0.0
  - fulltextsearch_elasticsearch: 29.0.1
  - groupfolders: 18.0.1
  - integration_gitlab: 3.1.1
  - logreader: 3.0.0
  - lookup_server_connector: 1.18.0
  - mail: 4.0.0
  - nextcloud_announcements: 2.0.0
  - notes: 4.10.1
  - notifications: 3.0.0
  - oauth2: 1.18.1
  - oidc_login: 3.1.1
  - password_policy: 2.0.0
  - photos: 3.0.2
  - polls: 7.2.3
  - privacy: 2.0.0
  - provisioning_api: 1.20.0
  - recognize: 8.0.0
  - recommendations: 3.0.0
  - related_resources: 1.5.0
  - richdocuments: 8.5.0
  - serverinfo: 2.0.0
  - settings: 1.13.0
  - sharebymail: 1.20.0
  - support: 2.0.0
  - survey_client: 2.0.0
  - suspicious_login: 8.0.0
  - systemtags: 1.20.0
  - tasks: 0.16.1
  - text: 4.1.0
  - theming: 2.5.0
  - twofactor_backupcodes: 1.19.0
  - twofactor_totp: 12.0.0-dev
  - updatenotification: 1.20.0
  - user_migration: 7.0.1
  - user_status: 1.10.0
  - viewer: 3.0.0
  - weather_status: 1.10.0
  - webhook_listeners: 1.1.0-dev
  - workflowengine: 2.12.0
Disabled:
  - bookmarks_fulltextsearch: 1.2.0 (installed 1.2.0)
  - encryption: 2.18.0
  - files_external: 1.22.0
  - twofactor_nextcloud_notification: 4.0.0
  - user_ldap: 1.21.0

Nextcloud Signing status

No errors have been found.

Nextcloud Logs

{
  "reqId": "GcrC6nW8dnGiNPCbuZjY",
  "level": 3,
  "time": "2024-09-16T08:35:03+00:00",
  "remoteAddr": "2a02:3100:xxx",
  "user": "d.xxx",
  "app": "webdav",
  "method": "PUT",
  "url": "/remote.php/dav/calendars/d.xxx/migrated-personal/416a2afc-de72-436e-ba46-ca889b6e8fe6.ics",
  "message": "DateTimeZone::__construct(): Unknown or bad timezone (W. Europe Standard Time)",
  "userAgent": "eMClient/10.0.3530.0",
  "version": "30.0.0.14",
  "exception": {
    "Exception": "Exception",
    "Message": "DateTimeZone::__construct(): Unknown or bad timezone (W. Europe Standard Time)",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/aditcloud/htdocs/nextcloud/apps/dav/lib/CalDAV/EventReader.php",
        "line": 131,
        "function": "__construct",
        "class": "DateTimeZone",
        "type": "->",
        "args": [
          "W. Europe Standard Time"
        ]
      },
      {
        "file": "/var/www/aditcloud/htdocs/nextcloud/apps/dav/lib/CalDAV/Schedule/IMipService.php",
        "line": 140,
        "function": "__construct",
        "class": "OCA\\DAV\\CalDAV\\EventReader",
        "type": "->",
        "args": [
          [
            "Sabre\\VObject\\Component\\VEvent",
            [
              "Sabre\\VObject\\Component\\VCalendar",
              "*** sensitive parameters replaced ***",
              "VCALENDAR"
            ],
            "VEVENT"
          ]
        ]
      },
      {
        "file": "/var/www/aditcloud/htdocs/nextcloud/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php",
        "line": 210,
        "function": "buildBodyData",
        "class": "OCA\\DAV\\CalDAV\\Schedule\\IMipService",
        "type": "->",
        "args": [
          [
            "Sabre\\VObject\\Component\\VEvent",
            [
              "Sabre\\VObject\\Component\\VCalendar",
              "*** sensitive parameters replaced ***",
              "VCALENDAR"
            ],
            "VEVENT"
          ],
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/aditcloud/htdocs/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
        "line": 89,
        "function": "schedule",
        "class": "OCA\\DAV\\CalDAV\\Schedule\\IMipPlugin",
        "type": "->",
        "args": [
          [
            "Sabre\\VObject\\ITip\\Message",
            "416a2afc-de72-436e-ba46-ca889b6e8fe6",
            "VEVENT",
            "REQUEST",
            3,
            "mailto:d.xxx@xxx.de",
            [
              "Sabre\\VObject\\Parameter",
              "*** sensitive parameters replaced ***",
              "CN",
              false
            ],
            "mailto:xxx.xx@xx.de",
            "xxx xxx",
            "3.7;Could not find principal.",
            [
              "Sabre\\VObject\\Component\\VCalendar",
              "*** sensitive parameters replaced ***",
              "VCALENDAR"
            ],
            true
          ]
        ]
      },
      {
        "file": "/var/www/aditcloud/htdocs/nextcloud/3rdparty/sabre/dav/lib/CalDAV/Schedule/Plugin.php",
        "line": 350,
        "function": "emit",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": [
          "schedule",
          [
            [
              "Sabre\\VObject\\ITip\\Message",
              "416a2afc-de72-436e-ba46-ca889b6e8fe6",
              "VEVENT",
              "REQUEST",
              3,
              "mailto:d.xxx@xxx.de",
              [
                "Sabre\\VObject\\Parameter",
                "*** sensitive parameters replaced ***",
                "CN",
                false
              ],
              "mailto:xxx.xxx@xxx.de",
              "xxx xxx",
              "3.7;Could not find principal.",
              [
                "Sabre\\VObject\\Component\\VCalendar",
                "*** sensitive parameters replaced ***",
                "VCALENDAR"
              ],
              true
            ]
          ]
        ]
      },
      {
        "file": "/var/www/aditcloud/htdocs/nextcloud/3rdparty/sabre/dav/lib/CalDAV/Schedule/Plugin.php",
        "line": 626,
        "function": "deliver",
        "class": "Sabre\\CalDAV\\Schedule\\Plugin",
        "type": "->",
        "args": [
          [
            "Sabre\\VObject\\ITip\\Message",
            "416a2afc-de72-436e-ba46-ca889b6e8fe6",
            "VEVENT",
            "REQUEST",
            3,
            "mailto:d.xxx@xxx.de",
            [
              "Sabre\\VObject\\Parameter",
              "*** sensitive parameters replaced ***",
              "CN",
              false
            ],
            "mailto:xxx.xxx@xxx.de",
            "xxx xxx",
            "3.7;Could not find principal.",
            [
              "Sabre\\VObject\\Component\\VCalendar",
              "*** sensitive parameters replaced ***",
              "VCALENDAR"
            ],
            true
          ]
        ]
      },
      {
        "file": "/var/www/aditcloud/htdocs/nextcloud/apps/dav/lib/CalDAV/Schedule/Plugin.php",
        "line": 190,
        "function": "processICalendarChange",
        "class": "Sabre\\CalDAV\\Schedule\\Plugin",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***",
          [
            "Sabre\\VObject\\Component\\VCalendar",
            "*** sensitive parameters replaced ***",
            "VCALENDAR"
          ],
          [
            "mailto:d.xxx@xxx.de",
            "/remote.php/dav/principals/users/d.xxx/"
          ],
          [],
          true
        ]
      },
      {
        "file": "/var/www/aditcloud/htdocs/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
        "line": 89,
        "function": "calendarObjectChange",
        "class": "OCA\\DAV\\CalDAV\\Schedule\\Plugin",
        "type": "->",
        "args": [
          [
            "Sabre\\HTTP\\Request"
          ],
          [
            "Sabre\\HTTP\\Response"
          ],
          [
            "Sabre\\VObject\\Component\\VCalendar",
            "*** sensitive parameters replaced ***",
            "VCALENDAR"
          ],
          "calendars/d.xxx/migrated-personal",
          true,
          true
        ]
      },
      {
        "file": "/var/www/aditcloud/htdocs/nextcloud/3rdparty/sabre/dav/lib/CalDAV/Plugin.php",
        "line": 889,
        "function": "emit",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": [
          "calendarObjectChange",
          [
            [
              "Sabre\\HTTP\\Request"
            ],
            [
              "Sabre\\HTTP\\Response"
            ],
            [
              "Sabre\\VObject\\Component\\VCalendar",
              "*** sensitive parameters replaced ***",
              "VCALENDAR"
            ],
            "calendars/d.xxx/migrated-personal",
            true,
            true
          ]
        ]
      },
      {
        "file": "/var/www/aditcloud/htdocs/nextcloud/3rdparty/sabre/dav/lib/CalDAV/Plugin.php",
        "line": 760,
        "function": "validateICalendar",
        "class": "Sabre\\CalDAV\\Plugin",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***",
          "*** sensitive parameters replaced ***",
          false,
          [
            "Sabre\\HTTP\\Request"
          ],
          [
            "Sabre\\HTTP\\Response"
          ],
          true
        ]
      },
      {
        "file": "/var/www/aditcloud/htdocs/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
        "line": 89,
        "function": "beforeCreateFile",
        "class": "Sabre\\CalDAV\\Plugin",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***",
          "*** sensitive parameters replaced ***",
          [
            "OCA\\DAV\\CalDAV\\Calendar"
          ],
          false
        ]
      },
      {
        "file": "/var/www/aditcloud/htdocs/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 1094,
        "function": "emit",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": [
          "beforeCreateFile",
          [
            "*** sensitive parameters replaced ***",
            "*** sensitive parameters replaced ***",
            [
              "OCA\\DAV\\CalDAV\\Calendar"
            ],
            false
          ]
        ]
      },
      {
        "file": "/var/www/aditcloud/htdocs/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php",
        "line": 504,
        "function": "createFile",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/aditcloud/htdocs/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
        "line": 89,
        "function": "httpPut",
        "class": "Sabre\\DAV\\CorePlugin",
        "type": "->",
        "args": [
          [
            "Sabre\\HTTP\\Request"
          ],
          [
            "Sabre\\HTTP\\Response"
          ]
        ]
      },
      {
        "file": "/var/www/aditcloud/htdocs/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 472,
        "function": "emit",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": [
          "method:PUT",
          [
            [
              "Sabre\\HTTP\\Request"
            ],
            [
              "Sabre\\HTTP\\Response"
            ]
          ]
        ]
      },
      {
        "file": "/var/www/aditcloud/htdocs/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 253,
        "function": "invokeMethod",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": [
          [
            "Sabre\\HTTP\\Request"
          ],
          [
            "Sabre\\HTTP\\Response"
          ]
        ]
      },
      {
        "file": "/var/www/aditcloud/htdocs/nextcloud/apps/dav/lib/Server.php",
        "line": 370,
        "function": "start",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/aditcloud/htdocs/nextcloud/apps/dav/appinfo/v2/remote.php",
        "line": 19,
        "function": "exec",
        "class": "OCA\\DAV\\Server",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/aditcloud/htdocs/nextcloud/remote.php",
        "line": 146,
        "args": [
          "/var/www/aditcloud/htdocs/nextcloud/apps/dav/appinfo/v2/remote.php"
        ],
        "function": "require_once"
      }
    ],
    "File": "/var/www/aditcloud/htdocs/nextcloud/apps/dav/lib/CalDAV/EventReader.php",
    "Line": 131,
    "message": "DateTimeZone::__construct(): Unknown or bad timezone (W. Europe Standard Time)",
    "exception": {},
    "CustomMessage": "DateTimeZone::__construct(): Unknown or bad timezone (W. Europe Standard Time)"
  }
}

Additional info

I've compared the code of the "dav" app from v29 to v30. The newly introduced "EventReader" class directly hands over the TZID to DateTime when being called in buildBodyData - while previously generateWhenString() relied on Property\ICalendar\DateTime $dtstart.

The timezone submitted by emClient is the default naming in Windows. There seems to be a mapping from Windows timezone names to Linux (e.g., in https://stackoverflow.com/questions/4967903/linux-windows-timezone-mapping ). Others recommend using the Caldav Synchronizer in Outlook (which my colleague doesn't use).

solracsf commented 1 month ago

Just a side note: https://github.com/abdulsametsahin/php-timezone-converter

antondollmaier commented 1 month ago

Please find a test ical file attached (rename to .ics): test_ics.txt

dziemann commented 4 days ago

Is there any update on this? Do we have a workaround? Facing the same issue with Outlook and CalDav Synchronizer and Nextcloud Server version 30.

apps/dav/lib/CalDAV/EventReader.php","Line":131,"message":"DateTimeZone::construct(): Unknown or bad timezone (W. Europe Standard Time)","exception":{},"CustomMessage":"DateTimeZone::construct(): Unknown or bad timezone (W. Europe Standard Time)"}}

IchoTolot commented 4 days ago

Ok, the root cause seems to be that "W. Europe Standard Time" is not an IANA Timezone but a windows timezone. But IMHO PHP needs IANA timezones and therefore the exception. For whatever reason, nextcloud suddenly can no longer cope with this. A workaround in the em-client is to simply specify the time zone explicitly for an appointment, then it works. Unfortunately, this does not work when moving from one calendar to another, as the em-client uses the Windows time zone again. Therefore, a fix in nextcloud would be wonderful ;-)

Nopsty commented 4 days ago

Same problem here with "Romance Standard Time". Nothing changed on the client side.

dziemann commented 3 days ago

Ok, the root cause seems to be that "W. Europe Standard Time" is not an IANA Timezone but a windows timezone. But IMHO PHP needs IANA timezones and therefore the exception. For whatever reason, nextcloud suddenly can no longer cope with this. A workaround in the em-client is to simply specify the time zone explicitly for an appointment, then it works. Unfortunately, this does not work when moving from one calendar to another, as the em-client uses the Windows time zone again. Therefore, a fix in nextcloud would be wonderful ;-)

Not sure if it is only the timezone. It's only affecting certain appointments. I have appointments with timezone "W. Europe Standard" without problem. But there are appointments with other attendees invited and after they accept the invitation the error occurs for each sync.

GMellar commented 16 hours ago

I have the same issue but with "DateTimeZone::__construct(): Unknown or bad timezone (W. Europe Standard Time)" on the latest Nextcloud Version with debian 12 and php 8.2.24. The calendar in the browser no longer loads completely.