summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2012-07-06 13:24:56 +0200
committerThomas Tanghus <thomas@tanghus.net>2012-07-06 13:24:56 +0200
commitcafbd023379073623295d11ae06be55a5f2cb569 (patch)
treed68b4c87c2b0e7a6016b584dbd8574235a5e92a9
parenta1872412bf24e175f4545216b597963137945aad (diff)
downloadnextcloud-server-cafbd023379073623295d11ae06be55a5f2cb569.tar.gz
nextcloud-server-cafbd023379073623295d11ae06be55a5f2cb569.zip
Fix endless loop when no addressbooks.
-rw-r--r--apps/contacts/lib/addressbook.php13
1 files changed, 10 insertions, 3 deletions
diff --git a/apps/contacts/lib/addressbook.php b/apps/contacts/lib/addressbook.php
index 40675efd8b4..7549464f464 100644
--- a/apps/contacts/lib/addressbook.php
+++ b/apps/contacts/lib/addressbook.php
@@ -148,10 +148,17 @@ class OC_Contacts_Addressbook{
* @return insertid
*/
public static function add($uid,$name,$description=''){
- $all = self::all($uid);
+ try {
+ $stmt = OCP\DB::prepare( 'SELECT uri FROM *PREFIX*contacts_addressbooks WHERE userid = ? ' );
+ $result = $stmt->execute(array($uid));
+ } catch(Exception $e) {
+ OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.' exception: '.$e->getMessage(),OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.' uid: '.$uid,OCP\Util::DEBUG);
+ return false;
+ }
$uris = array();
- foreach($all as $i){
- $uris[] = $i['uri'];
+ while($row = $result->fetchRow()){
+ $uris[] = $row['uri'];
}
$uri = self::createURI($name, $uris );