summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2012-07-30 12:28:10 +0200
committerThomas Tanghus <thomas@tanghus.net>2012-07-30 12:28:10 +0200
commitf91783e9ab622c6ee90affb2a76ff2bef13e8328 (patch)
tree007a71ca20e5e1b5158d98328ee27cf966dabf1d /apps
parente52ab59b404d6d35ed8619da35b1f70404359212 (diff)
downloadnextcloud-server-f91783e9ab622c6ee90affb2a76ff2bef13e8328.tar.gz
nextcloud-server-f91783e9ab622c6ee90affb2a76ff2bef13e8328.zip
Fix errors when no addressbook.
Diffstat (limited to 'apps')
-rw-r--r--apps/contacts/lib/addressbook.php24
-rw-r--r--apps/contacts/lib/vcard.php7
2 files changed, 19 insertions, 12 deletions
diff --git a/apps/contacts/lib/addressbook.php b/apps/contacts/lib/addressbook.php
index 73b30e942fa..634d59eb9bd 100644
--- a/apps/contacts/lib/addressbook.php
+++ b/apps/contacts/lib/addressbook.php
@@ -71,10 +71,15 @@ class OC_Contacts_Addressbook{
* @return associative array
*/
public static function find($id){
- $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*contacts_addressbooks WHERE id = ?' );
- $result = $stmt->execute(array($id));
-
- return $result->fetchRow();
+ try {
+ $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*contacts_addressbooks WHERE id = ?' );
+ $result = $stmt->execute(array($id));
+ return $result->fetchRow();
+ } catch(Exception $e) {
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', id: '.$id, OCP\Util::DEBUG);
+ return false;
+ }
}
/**
@@ -171,7 +176,7 @@ class OC_Contacts_Addressbook{
$prefbooks = OCP\Config::getUserValue($uid,'contacts','openaddressbooks',null);
$prefbooks = explode(';',$prefbooks);
for ($i = 0; $i < count($prefbooks); $i++) {
- if(!self::find($prefbooks[$i])) {
+ if(!$prefbooks[$i] || !self::find($prefbooks[$i])) {
unset($prefbooks[$i]);
}
}
@@ -207,16 +212,15 @@ class OC_Contacts_Addressbook{
try {
$stmt = OCP\DB::prepare( $prep );
$result = $stmt->execute($active);
+ while( $row = $result->fetchRow()){
+ $addressbooks[] = $row;
+ }
} catch(Exception $e) {
OCP\Util::writeLog('contacts','OC_Contacts_Addressbook:active:, exception: '.$e->getMessage(),OCP\Util::DEBUG);
OCP\Util::writeLog('contacts','OC_Contacts_Addressbook:active, ids: '.join(',', $active),OCP\Util::DEBUG);
OCP\Util::writeLog('contacts','OC_Contacts_Addressbook::active, SQL:'.$prep,OCP\Util::DEBUG);
}
- while( $row = $result->fetchRow()){
- $addressbooks[] = $row;
- }
-
return $addressbooks;
}
@@ -239,7 +243,7 @@ class OC_Contacts_Addressbook{
if(!in_array($id, $openaddressbooks)) {
$openaddressbooks[] = $id;
}
- } else {
+ } else {
if(in_array($id, $openaddressbooks)) {
unset($openaddressbooks[array_search($id, $openaddressbooks)]);
}
diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php
index 2868643387d..7c8dbd2ee49 100644
--- a/apps/contacts/lib/vcard.php
+++ b/apps/contacts/lib/vcard.php
@@ -62,6 +62,9 @@ class OC_Contacts_VCard{
}
} elseif($id) {
if(is_array($id)) {
+ if(count($id) == 0) {
+ return array();
+ }
$id = $id[0];
}
try {
@@ -110,7 +113,7 @@ class OC_Contacts_VCard{
return $result->fetchRow();
}
- /**
+ /**
* @brief Format property TYPE parameters for upgrading from v. 2.1
* @param $property Reference to a Sabre_VObject_Property.
* In version 2.1 e.g. a phone can be formatted like: TEL;HOME;CELL:123456789
@@ -126,7 +129,7 @@ class OC_Contacts_VCard{
}
}
- /**
+ /**
* @brief Decode properties for upgrading from v. 2.1
* @param $property Reference to a Sabre_VObject_Property.
* The only encoding allowed in version 3.0 is 'b' for binary. All encoded strings