server icon indicating copy to clipboard operation
server copied to clipboard

[Bug]: Array to string conversion in CalDAV backend

Open ChristophWurst opened this issue 3 years ago • 41 comments

⚠️ This issue respects the following points: ⚠️

  • [X] This is a bug, not a question or a configuration/webserver/proxy issue.
  • [X] This issue is not already reported on Github (I've searched it).
  • [X] Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
  • [X] Nextcloud Server is running on 64bit capable CPU, PHP and OS.
  • [X] I agree to follow Nextcloud's Code of Conduct.

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?

  • [ ] Default user-backend (database)
  • [X] LDAP/ Active Directory
  • [ ] SSO - SAML
  • [ ] Other

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 avatar Mar 03 '23 07:03 ChristophWurst

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

ChristophWurst avatar Mar 03 '23 07:03 ChristophWurst

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

tcitworld avatar Mar 20 '23 13:03 tcitworld

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?

kartoffelheinz avatar Jul 19 '23 08:07 kartoffelheinz

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]"
}

Pazu avatar Nov 05 '23 18:11 Pazu

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) : [];

solracsf avatar Nov 12 '23 22:11 solracsf

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"
}

jameskimmel avatar Feb 28 '24 09:02 jameskimmel

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.

joshtrichards avatar Feb 28 '24 15:02 joshtrichards

Still having this problem on 29.0.6

prismopensource avatar Sep 11 '24 15:09 prismopensource

Still having this problem on 29.0.7

Jolopu avatar Sep 26 '24 12:09 Jolopu

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. :)

joshtrichards avatar Sep 26 '24 13:09 joshtrichards

Also on my instance 30.0.1

What about a fix or update?

Quake85 avatar Oct 23 '24 20:10 Quake85

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.

edit on Sept 2026 : Missing events on Iphone was not related to this bug but to mis-encoded events. Our fault.

Mer0me avatar Nov 05 '24 16:11 Mer0me

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": "..."
}

guckuck avatar Nov 07 '24 15:11 guckuck

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

thibs43 avatar Nov 14 '24 08:11 thibs43

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

Quake85 avatar Nov 14 '24 10:11 Quake85

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.

jameskimmel avatar Nov 14 '24 14:11 jameskimmel

Hi Everyone,

Would anyone with this issue here be able to provide a transmission intercept capture? As I don't have a Mac or iDevice to test with.

This seems to be caused by the MOVE method, but I need a reliable way to reproduce this issue to test and fix.

SebastianKrupinski avatar Dec 06 '24 20:12 SebastianKrupinski

Hey Sebastian, If you could describe me what exactly to do, I can do this. At the Moment I don‘t know exactly what you mean.

Quake85 avatar Dec 06 '24 21:12 Quake85

Hey Sebastian, If you could describe me what exactly to do, I can do this. At the Moment I don‘t know exactly what you mean.

I need to see the commands that the mac app is sending, the easiest way to do this would be to use tcpdump on the server and setup the Mac client to connect to NC over non encrypted HTTP.

tcpdump -i <interface> -w <output_file> port 80

SebastianKrupinski avatar Dec 06 '24 21:12 SebastianKrupinski

You could also use something like mitmproxy to capture the encrypted connection if a HTTP setup or connection is not possible.

SebastianKrupinski avatar Dec 06 '24 21:12 SebastianKrupinski