summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/vcategories.php16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/vcategories.php b/lib/vcategories.php
index ec243297a43..116c1d1cd95 100644
--- a/lib/vcategories.php
+++ b/lib/vcategories.php
@@ -632,9 +632,11 @@ class OC_VCategories {
OC_Log::write('core', __METHOD__ . ', before: '
. print_r(self::$categories, true), OC_Log::DEBUG);
foreach($names as $name) {
+ $id = null;
OC_Log::write('core', __METHOD__.', '.$name, OC_Log::DEBUG);
if($this->hasCategory($name)) {
- unset(self::$categories[$this->array_searchi($name, self::$categories)]);
+ $id = $this->array_searchi($name, self::$categories);
+ unset(self::$categories[$id]);
}
try {
$stmt = OCP\DB::prepare('DELETE FROM `' . self::CATEGORY_TABLE . '` WHERE '
@@ -644,6 +646,18 @@ class OC_VCategories {
OCP\Util::writeLog('core', __METHOD__ . ', exception: '
. $e->getMessage(), OCP\Util::ERROR);
}
+ if(!is_null($id) && $id !== false) {
+ try {
+ $sql = 'DELETE FROM `' . self::RELATION_TABLE . '` '
+ . 'WHERE `categoryid` = ?';
+ $stmt = OCP\DB::prepare($sql);
+ $stmt->execute(array($id));
+ } catch(Exception $e) {
+ OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
+ OCP\Util::ERROR);
+ return false;
+ }
+ }
}
OC_Log::write('core', __METHOD__.', after: '
. print_r(self::$categories, true), OC_Log::DEBUG);