From b71cf1a4f97bb660a279a16ca4da864b56986a59 Mon Sep 17 00:00:00 2001
From: Thomas Tanghus <thomas@tanghus.net>
Date: Sat, 7 Apr 2012 16:01:50 +0200
Subject: [PATCH] Fix bug oc-413: PHP fatal error in contacts page when no
 contacts in ownCloud.

---
 apps/contacts/index.php | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/apps/contacts/index.php b/apps/contacts/index.php
index 076b10c2ee..776c57ca60 100644
--- a/apps/contacts/index.php
+++ b/apps/contacts/index.php
@@ -43,17 +43,15 @@ if(count($categories) == 0) {
 			$vcaddressbookids[] = $vcaddressbook['id'];
 		} 
 		$vccontacts = OC_Contacts_VCard::all($vcaddressbookids);
-		if(count($vccontacts) == 0) {
-			bailOut(OC_Contacts_App::$l10n->t('No contacts found.'));
-		}
-
-		$cards = array();
-		foreach($vccontacts as $vccontact) {
-			$cards[] = $vccontact['carddata'];
-		} 
+		if(count($vccontacts) > 0) {
+			$cards = array();
+			foreach($vccontacts as $vccontact) {
+				$cards[] = $vccontact['carddata'];
+			} 
 
-		OC_Contacts_App::$categories->rescan($cards);
-		$categories = OC_Contacts_App::$categories->categories();
+			OC_Contacts_App::$categories->rescan($cards);
+			$categories = OC_Contacts_App::$categories->categories();
+		}
 	}
 }
 
-- 
GitLab