summaryrefslogtreecommitdiffstats
path: root/lib/vcategories.php
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2012-10-24 22:39:34 +0200
committerThomas Tanghus <thomas@tanghus.net>2012-10-24 22:39:34 +0200
commit2fc495a91a1c38e0fbf53f0c78d157698e7ff024 (patch)
tree2533dbfbfeb26790d4a186947bc7daadf8b67fd5 /lib/vcategories.php
parent675a56c5ed798afae6bc9e56616f948a2c4496c2 (diff)
downloadnextcloud-server-2fc495a91a1c38e0fbf53f0c78d157698e7ff024.tar.gz
nextcloud-server-2fc495a91a1c38e0fbf53f0c78d157698e7ff024.zip
Also delete category/object relations when deleting a category.
Diffstat (limited to 'lib/vcategories.php')
-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);