From 95cdb64b143dd2851009af5754dc0fcea82e9d1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20R=C3=BCegg?= Date: Fri, 13 Feb 2015 04:25:48 +0100 Subject: [PATCH 1/2] Avoid "Undefined offset: 0" $addressBook is always an array. either empty or having one entry. https://github.com/owncloud/contacts/issues/740 https://github.com/nerzhul/ocsms/issues/39 --- lib/backend/shared.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/backend/shared.php b/lib/backend/shared.php index 43a09071..aa6b354c 100644 --- a/lib/backend/shared.php +++ b/lib/backend/shared.php @@ -87,8 +87,22 @@ class Shared extends Database { // Not sure if I'm doing it wrongly, or if its supposed to return // the info in an array? - $addressBook = (isset($addressBook['permissions']) ? $addressBook : $addressBook[0]); - + // https://github.com/owncloud/core/blob/master/lib/private/share/share.php + // \-> getItemSharedWithBySource() + // \-> self::getItems() + // -> return array(); + // or -> return formatResult(); + // \-> https://github.com/owncloud/contacts/blob/master/lib/share/addressbook.php + // \-> formatItems() + // \--> which in turn also always returns an array + // thus $addressBook is an array. either empty or having one entry + + if(count($addressBook) == 0) { + return null; + } + + $addressBook = $addressBook[0]; + if(!isset($addressBook['permissions'])) { return null; } From f941a3083877b3ea1918083f4a5ddcde313a2059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20R=C3=BCegg?= Date: Fri, 13 Feb 2015 11:14:59 +0100 Subject: [PATCH 2/2] move comments to commit comment // Not sure if I'm doing it wrongly, or if its supposed to return // the info in an array? // https://github.com/owncloud/core/blob/master/lib/private/share/share.php // \-> getItemSharedWithBySource() // \-> self::getItems() // -> return array(); // or -> return formatResult(); // \-> https://github.com/owncloud/contacts/blob/master/lib/share/addressbook.php // \-> formatItems() // \--> which in turn also always returns an array // thus $addressBook is an array. either empty or having one entry --- lib/backend/shared.php | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/lib/backend/shared.php b/lib/backend/shared.php index aa6b354c..1d39f69a 100644 --- a/lib/backend/shared.php +++ b/lib/backend/shared.php @@ -85,18 +85,6 @@ class Shared extends Database { Contacts\Share\Addressbook::FORMAT_ADDRESSBOOKS ); - // Not sure if I'm doing it wrongly, or if its supposed to return - // the info in an array? - // https://github.com/owncloud/core/blob/master/lib/private/share/share.php - // \-> getItemSharedWithBySource() - // \-> self::getItems() - // -> return array(); - // or -> return formatResult(); - // \-> https://github.com/owncloud/contacts/blob/master/lib/share/addressbook.php - // \-> formatItems() - // \--> which in turn also always returns an array - // thus $addressBook is an array. either empty or having one entry - if(count($addressBook) == 0) { return null; }