From 26618704a924723505be7b723e90c63055017658 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Sat, 20 Oct 2012 13:45:18 +0200 Subject: [PATCH] Fix accidentally creating new categories with the id as name. --- lib/vcategories.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/vcategories.php b/lib/vcategories.php index 2ea70d167f..c220821eca 100644 --- a/lib/vcategories.php +++ b/lib/vcategories.php @@ -149,7 +149,7 @@ class OC_VCategories { } return $catmap; } - + // Don't add favorites to normal categories. $favpos = array_search(self::CATEGORY_FAVORITE, $categories); if($favpos !== false) { @@ -569,12 +569,14 @@ class OC_VCategories { */ public function addToCategory($objid, $category, $type = null) { $type = is_null($type) ? $this->type : $type; - if(is_string($category) && !$this->hasCategory($category)) { - $this->add($category, true); + if(is_string($category) && !is_numeric($category)) { + if(!$this->hasCategory($category)) { + $this->add($category, true); + } + $categoryid = $this->array_searchi($category, self::$categories); + } else { + $categoryid = $category; } - $categoryid = (is_string($category) && !is_numeric($category)) - ? $this->array_searchi($category, self::$categories) - : $category; try { OCP\DB::insertIfNotExist(self::RELATION_TABLE, array( @@ -711,3 +713,4 @@ class OC_VCategories { } } +