1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2025-01-19 08:52:22 +01:00

Fix endless loop when no addressbooks.

This commit is contained in:
Thomas Tanghus 2012-07-06 13:24:56 +02:00
parent d08ea43b81
commit 412a583213

View File

@ -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 );