CalDAV StatusService.php causing a lot of exceptions (fixed)

Nextcloud version: 28.0.2
Operating system and version: Arch Linux (6.7.3-hardened1-3-hardened)
Apache or nginx version: nginx/1.24.0
PHP version: php-legacy 8.1.27-2

The issue you are facing:
I am getting a lot of errors, that i have never seen before, but can’t figure out how to fix them. It also seems like, these errors only occur, when i actually use the website, so it must be something related to browsing the stuff or something.

Is this the first time you’ve seen this error? Yes:

Steps to replicate it:

  1. unknown

The output of your Nextcloud log in Admin > Logging:

{
  "reqId": "g4mPDloXvmOiaoVpfju9",
  "level": 3,
  "time": "2024-02-13T01:07:54+00:00",
  "remoteAddr": "172.70.122.245",
  "user": "passihd",
  "app": "no app in context",
  "method": "PUT",
  "url": "/ocs/v2.php/apps/user_status/api/v1/heartbeat?format=json",
  "message": "Exception thrown: Exception",
  "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0",
  "version": "28.0.2.5",
  "exception": {
    "Exception": "Exception",
    "Message": "Call to a member function getTimestamp() on array in file '/usr/share/webapps/nextcloud/apps/dav/lib/CalDAV/Status/StatusService.php' line 109",
    "Code": 0,
    "Trace": [
      {
        "file": "/usr/share/webapps/nextcloud/lib/private/AppFramework/App.php",
        "line": 184,
        "function": "dispatch",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->"
      },
      {
        "file": "/usr/share/webapps/nextcloud/lib/private/Route/Router.php",
        "line": 315,
        "function": "main",
        "class": "OC\\AppFramework\\App",
        "type": "::"
      },
      {
        "file": "/usr/share/webapps/nextcloud/ocs/v1.php",
        "line": 65,
        "function": "match",
        "class": "OC\\Route\\Router",
        "type": "->"
      },
      {
        "file": "/usr/share/webapps/nextcloud/ocs/v2.php",
        "line": 23,
        "args": [
          "/usr/share/webapps/nextcloud/ocs/v1.php"
        ],
        "function": "require_once"
      }
    ],
    "File": "/usr/share/webapps/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
    "Line": 169,
    "Previous": {
      "Exception": "Error",
      "Message": "Call to a member function getTimestamp() on array",
      "Code": 0,
      "Trace": [
        {
          "function": "OCA\\DAV\\CalDAV\\Status\\{closure}",
          "class": "OCA\\DAV\\CalDAV\\Status\\StatusService",
          "type": "::",
          "args": [
            "*** sensitive parameters replaced ***"
          ]
        },
        {
          "file": "/usr/share/webapps/nextcloud/apps/dav/lib/CalDAV/Status/StatusService.php",
          "line": 119,
          "function": "array_filter"
        },
        {
          "file": "/usr/share/webapps/nextcloud/apps/user_status/lib/Listener/UserLiveStatusListener.php",
          "line": 73,
          "function": "processCalendarStatus",
          "class": "OCA\\DAV\\CalDAV\\Status\\StatusService",
          "type": "->"
        },
        {
          "file": "/usr/share/webapps/nextcloud/lib/private/EventDispatcher/ServiceEventListener.php",
          "line": 86,
          "function": "handle",
          "class": "OCA\\UserStatus\\Listener\\UserLiveStatusListener",
          "type": "->"
        },
        {
          "file": "/usr/share/webapps/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
          "line": 230,
          "function": "__invoke",
          "class": "OC\\EventDispatcher\\ServiceEventListener",
          "type": "->"
        },
        {
          "file": "/usr/share/webapps/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
          "line": 59,
          "function": "callListeners",
          "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
          "type": "->"
        },
        {
          "file": "/usr/share/webapps/nextcloud/lib/private/EventDispatcher/EventDispatcher.php",
          "line": 94,
          "function": "dispatch",
          "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
          "type": "->"
        },
        {
          "file": "/usr/share/webapps/nextcloud/lib/private/EventDispatcher/EventDispatcher.php",
          "line": 106,
          "function": "dispatch",
          "class": "OC\\EventDispatcher\\EventDispatcher",
          "type": "->"
        },
        {
          "file": "/usr/share/webapps/nextcloud/apps/user_status/lib/Controller/HeartbeatController.php",
          "line": 100,
          "function": "dispatchTyped",
          "class": "OC\\EventDispatcher\\EventDispatcher",
          "type": "->"
        },
        {
          "file": "/usr/share/webapps/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
          "line": 230,
          "function": "heartbeat",
          "class": "OCA\\UserStatus\\Controller\\HeartbeatController",
          "type": "->"
        },
        {
          "file": "/usr/share/webapps/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
          "line": 137,
          "function": "executeController",
          "class": "OC\\AppFramework\\Http\\Dispatcher",
          "type": "->"
        },
        {
          "file": "/usr/share/webapps/nextcloud/lib/private/AppFramework/App.php",
          "line": 184,
          "function": "dispatch",
          "class": "OC\\AppFramework\\Http\\Dispatcher",
          "type": "->"
        },
        {
          "file": "/usr/share/webapps/nextcloud/lib/private/Route/Router.php",
          "line": 315,
          "function": "main",
          "class": "OC\\AppFramework\\App",
          "type": "::"
        },
        {
          "file": "/usr/share/webapps/nextcloud/ocs/v1.php",
          "line": 65,
          "function": "match",
          "class": "OC\\Route\\Router",
          "type": "->"
        },
        {
          "file": "/usr/share/webapps/nextcloud/ocs/v2.php",
          "line": 23,
          "args": [
            "/usr/share/webapps/nextcloud/ocs/v1.php"
          ],
          "function": "require_once"
        }
      ],
      "File": "/usr/share/webapps/nextcloud/apps/dav/lib/CalDAV/Status/StatusService.php",
      "Line": 109
    },
    "CustomMessage": "Exception thrown: Exception"
  },
  "id": "65cac0f174d4e"
}

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'datadirectory' => '/var/lib/nextcloud/data',
  'logfile' => '/var/log/nextcloud/nextcloud.log',
  'default_phone_region' => 'DE',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    2 => '***redacted***',
  ),
  'overwrite.cli.url' => '***redacted***',
  'overwriteprotocol' => 'https',
  'htaccess.RewriteBase' => '/',
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/usr/share/webapps/nextcloud/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 => 
    array (
      'path' => '/var/lib/nextcloud/apps',
      'url' => '/wapps',
      'writable' => true,
    ),
  ),
  'passwordsalt' => '***redacted***',
  'secret' => '***redacted***',
  'dbtype' => 'mysql',
  'version' => '28.0.2.5',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost:3306',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => '***redacted***',
  'installed' => true,
  'instanceid' => '***redacted***',
  'maintenance' => false,
  'mail_from_address' => 'nextcloud',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => '***redacted***',
  'mail_smtpauth' => 1,
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtphost' => '***redacted***',
  'mail_smtpport' => '587',
  'mail_smtpname' => '***redacted***',
  'mail_smtppassword' => '***redacted***',
  'app_install_overwrite' => 
  array (
    0 => 'hsts',
    1 => 'hibp',
    2 => 'files_rightclick',
    3 => 'integration_twitter',
  ),
  'loglevel' => 2,
  'updater.secret' => '***redacted***',
  'maintenance_window_start' => 1,
  'filelocking.enabled' => true,
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '127.0.0.1',
    'port' => 6379,
  ),
);

Ok, so i figured out how to fix it!

Go to /path/to/your/instance/directory/apps/dav/lib/CalDAV/Status/StatusService.php, go to the problematic line and see if there is any $ signs missing.

Example:

broken line:

$timestamp = $dateTime->getTimestamp();

fixed line:

$timestamp = $dateTime-> $getTimestamp();

Its really dumb, but it fixes all the errors