nextcloud / server

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

[Bug]: Array to string conversion in CalDAV backend #37025

Open ChristophWurst opened 1 year ago

ChristophWurst commented 1 year ago

⚠️ This issue respects the following points: ⚠️

Bug description

Array to string conversion at https://github.com/nextcloud/server/blob/v26.0.0rc1/apps/dav/lib/CalDAV/Activity/Backend.php#L561

https://github.com/nextcloud/server/blob/6466c8ee31f3b30b8710c91c05d4b88d1d7ef086/apps/dav/lib/CalDAV/Activity/Backend.php#L561

Steps to reproduce

  1. Connect mac os to Nextcloud's CalDAV backend
  2. ???

Expected behavior

No errors

Installation method

None

Operating system

None

PHP engine version

None

Web server

None

Database engine version

None

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

None

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?

Configuration report

n/a

List of activated Apps

n/a

Nextcloud Signing status

No response

Nextcloud Logs

{
  "reqId": "9DlC6Z02DsTFC2tvNxU2",
  "level": 3,
  "time": "2023-03-03T06:56:13+00:00",
  "remoteAddr": "redacted",
  "user": "user123",
  "app": "PHP",
  "method": "MOVE",
  "url": "/remote.php/dav/calendars/user123/personal/sabredav-abc-def-ghi.ics",
  "message": "Array to string conversion at /var/www/cloud.nextcloud.com/nextcloud/apps/dav/lib/CalDAV/Activity/Backend.php#561",
  "userAgent": "macOS/13.1 (22C65) dataaccessd/1.0",
  "version": "26.0.0.8",
  "data": {
    "app": "PHP"
  },
  "id": "123def567"
}

Additional info

No response

ChristophWurst commented 1 year ago

array_intersect does not like nested array: https://3v4l.org/TYrqn

tcitworld commented 1 year ago

I just saw the same thing (in 25). I don't see how shares can contain an array itself. :thinking:

kartoffelheinz commented 1 year ago

This bug prevents certain events from syncing (from Apple devices, mostly fantastical) and had been fixed in early 26 beta but apparently has now been re-introduced. Unfortunate. Any idea on when this is going to be fixed again?

Pazu commented 1 year ago

Still seeing this running 27.1.3:

{
    "reqId": "[removed]",
    "level": 3,
    "time": "2023-11-05T17:35:11+00:00",
    "remoteAddr": "[removed]",
    "user": "[removed]",
    "app": "PHP",
    "method": "MOVE",
    "url": "/remote.php/dav/calendars/[removed]/[removed]/[GUID].ics",
    "message": "Array to string conversion at /var/www/path_to_web_root/apps/dav/lib/CalDAV/Activity/Backend.php#561",
    "userAgent": "iOS/17.0.3 (21A360) dataaccessd/1.0",
    "version": "27.1.3.2",
    "data": {
        "app": "PHP"
    },
    "id": "[removed]"
}
solracsf commented 1 year ago

What if values are flatten before using the arrays, could this fix it?

$flatten = function ($array) use (&$flatten) {
    $result = [];
    foreach ($array as $value) {
        if (is_array($value)) {
            $result = array_merge($result, $flatten($value));
        } else {
            $result[] = $value;
        }
    }
    return $result;
};

$sourceShares = is_array($sourceShares) ? $flatten($sourceShares) : [];
$targetShares = is_array($targetShares) ? $flatten($targetShares) : [];
jameskimmel commented 8 months ago

Same error on 28.0.2


{
  "reqId": "removed",
  "level": 3,
  "time": "2024-02-21T11:07:11+00:00",
  "remoteAddr": "1.1.1.1",
  "user": "UserName1",
  "app": "PHP",
  "method": "MOVE",
  "url": "/remote.php/dav/calendars/UserName1/sitzungen_shared_by_UserName2/58B95D5D-32EA-490B-82E1-ADC31B854C3C.ics",
  "message": "Array to string conversion at /var/www/nextcloud/apps/dav/lib/CalDAV/Activity/Backend.php#561",
  "userAgent": "Mozilla/5.0 (iPad; CPU OS 15_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/121.0.6167.171 Mobile/15E148 Safari/604.1",
  "version": "28.0.2.5",
  "data": {
    "app": "PHP"
  },
  "id": "65defd55416b7"
}
joshtrichards commented 8 months ago

Same solution as used in #43794 should work here (using array_map serialize/unserialize different approach taken in the final merged PR, but same idea). I don't have a test setup for this, so I'll leave trying it to someone that feels like giving it a shot + can also reproduce this situation on-demand.

prismopensource commented 2 months ago

Still having this problem on 29.0.6

Jolopu commented 1 month ago

Still having this problem on 29.0.7

joshtrichards commented 1 month ago

Still having this problem on 29.0.7

A thumbs up / upvote on the initial issue is sufficient, unless you have new information to add. If the Issue is still open (like this one), it's assumed it still applies to all current releases already. :)

Quake85 commented 1 month ago

Also on my instance 30.0.1

What about a fix or update?

Mer0me commented 2 weeks ago

This bug prevents certain events from syncing (from Apple devices, mostly fantastical) and had been fixed in early 26 beta but apparently has now been re-introduced. Unfortunate. Any idea on when this is going to be fixed again?

We actually have some events not syncing only on some users' Iphones. Could you please develop your observations. It could help us to figure out what happened to these events. The Array to string error throws every time we move an event from a calendar to another. But there is no evident correlation between moved events and missing events on Iphones.

guckuck commented 2 weeks ago

I have this problem too. I just updated to 30.0.2. I will observe this problem ...

{
  "reqId": "removed",
  "level": 3,
  "time": "2024-11-05T05:39:20+00:00",
  "remoteAddr": "IP",
  "user": "user.name",
  "app": "PHP",
  "method": "MOVE",
  "url": "/remote.php/dav/calendars/user.name/personal/A2829EA6-94ED-4E01-8FAD-D1879CAA78BF.ics",
  "message": "Array to string conversion at /var/www/nextcloud/apps/dav/lib/CalDAV/Activity/Backend.php#541",
  "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:132.0) Gecko/20100101 Firefox/132.0",
  "version": "30.0.1.2",
  "data": {
    "app": "PHP"
  },
  "id": "..."
}
thibs43 commented 1 week ago

Hello, Also got this error here, nextcloud server Nextcloud Hub 9 (30.0.2) Client is on a Android phone syncing with calDav

[PHP] Error: Array to string conversion at /var/www/html/apps/dav/lib/CalDAV/Activity/Backend.php#541
    MOVE /remote.php/dav/calendars/---/personal/F3D54AEF-000-4D86-BB5A-D********75FAE.ics
    from 192.168.1.254 by *** at Nov 13, 2024, 10:13:11 PM
Quake85 commented 1 week ago

Yes, i also Updated to 30.0.2, Same Problem. Also fresh/new Installation in my testing environment.

Ist’s clear, that this is a bug.

So please dear developers clear this Problem.

Thanks a lot

jameskimmel commented 1 week ago

I know this does not help most of you guys, but I can only say that the issue is gone for me.

I updated to 30.0.2, reconfigured my NGINX reverse proxy to include this

    location /.well-known/carddav {
    return 301 $scheme://$host/remote.php/dav;
    }

    location /.well-known/caldav {
    return 301 $scheme://$host/remote.php/dav;
    }

and also installed the calender via profiles on my iPhone. Works perfect and nothing in the logs.