diff options
author | Thomas Tanghus <thomas@tanghus.net> | 2012-06-27 01:03:18 +0200 |
---|---|---|
committer | Thomas Tanghus <thomas@tanghus.net> | 2012-06-27 01:03:53 +0200 |
commit | a25ae4b4b66e54e627912e5691f01da998f17029 (patch) | |
tree | cdb1022f67e39c0068ef29f4549b3a40ca2451e6 /lib/vcategories.php | |
parent | f55f13eebc3c3f15e74a7026a058ffaa5079f0e3 (diff) | |
download | nextcloud-server-a25ae4b4b66e54e627912e5691f01da998f17029.tar.gz nextcloud-server-a25ae4b4b66e54e627912e5691f01da998f17029.zip |
Make Categories a bit quieter.
Diffstat (limited to 'lib/vcategories.php')
-rw-r--r-- | lib/vcategories.php | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/vcategories.php b/lib/vcategories.php index 1e79b62f0d6..8157c343868 100644 --- a/lib/vcategories.php +++ b/lib/vcategories.php @@ -55,7 +55,7 @@ class OC_VCategories { $this->app = $app; $this->user = is_null($user) ? OC_User::getUser() : $user; $categories = trim(OC_Preferences::getValue($this->user, $app, self::PREF_CATEGORIES_LABEL, '')); - $this->categories = $categories != '' ? unserialize($categories) : $defcategories; + $this->categories = $categories != '' ? @unserialize($categories) : $defcategories; } /** @@ -64,6 +64,9 @@ class OC_VCategories { */ public function categories() { //OC_Log::write('core','OC_VCategories::categories: '.print_r($this->categories, true), OC_Log::DEBUG); + if(!$this->categories) { + return array(); + } usort($this->categories, 'strnatcasecmp'); // usort to also renumber the keys return $this->categories; } @@ -203,11 +206,17 @@ class OC_VCategories { // case-insensitive in_array private function in_arrayi($needle, $haystack) { + if(!is_array($haystack)) { + return false; + } return in_array(strtolower($needle), array_map('strtolower', $haystack)); } // case-insensitive array_search private function array_searchi($needle, $haystack) { + if(!is_array($haystack)) { + return false; + } return array_search(strtolower($needle),array_map('strtolower',$haystack)); } |