diff options
author | Thomas Tanghus <thomas@tanghus.net> | 2012-02-14 02:15:21 +0100 |
---|---|---|
committer | Thomas Tanghus <thomas@tanghus.net> | 2012-02-14 02:15:21 +0100 |
commit | f7161bb48b6bb71b04f4167f8c4cfb4096824ed8 (patch) | |
tree | fee920a035ee9830a97dd6ae7d0ab791798f8951 /apps | |
parent | dc20900e10f9a080f1ffa164c1e6b0dd62f6c46b (diff) | |
download | nextcloud-server-f7161bb48b6bb71b04f4167f8c4cfb4096824ed8.tar.gz nextcloud-server-f7161bb48b6bb71b04f4167f8c4cfb4096824ed8.zip |
Added some error checking as mentioned in http://bugs.owncloud.org/thebuggenie/owncloud/issues/oc-227
Diffstat (limited to 'apps')
-rw-r--r-- | apps/contacts/lib/vcard.php | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php index cc25c009d67..ece203bd458 100644 --- a/apps/contacts/lib/vcard.php +++ b/apps/contacts/lib/vcard.php @@ -47,6 +47,7 @@ class OC_Contacts_VCard{ * ['carddata'] */ public static function all($id){ + $result = null; if(is_array($id)) { $id_sql = join(',', array_fill(0, count($id), '?')); $prep = 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid IN ('.$id_sql.') ORDER BY fullname'; @@ -58,13 +59,20 @@ class OC_Contacts_VCard{ OC_Log::write('contacts','OC_Contacts_VCard:all, ids: '.join(',', $id),OC_Log::DEBUG); OC_Log::write('contacts','SQL:'.$prep,OC_Log::DEBUG); } - } else { - $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ? ORDER BY fullname' ); - $result = $stmt->execute(array($id)); + } elseif($id) { + try { + $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ? ORDER BY fullname' ); + $result = $stmt->execute(array($id)); + } catch(Exception $e) { + OC_Log::write('contacts','OC_Contacts_VCard:all:, exception: '.$e->getMessage(),OC_Log::DEBUG); + OC_Log::write('contacts','OC_Contacts_VCard:all, ids: '. $id,OC_Log::DEBUG); + } } $cards = array(); - while( $row = $result->fetchRow()){ - $cards[] = $row; + if(!is_null($result)) { + while( $row = $result->fetchRow()){ + $cards[] = $row; + } } return $cards; |