diff options
author | Thomas Tanghus <thomas@tanghus.net> | 2012-10-24 22:39:34 +0200 |
---|---|---|
committer | Thomas Tanghus <thomas@tanghus.net> | 2012-10-24 22:39:34 +0200 |
commit | 2fc495a91a1c38e0fbf53f0c78d157698e7ff024 (patch) | |
tree | 2533dbfbfeb26790d4a186947bc7daadf8b67fd5 /lib/vcategories.php | |
parent | 675a56c5ed798afae6bc9e56616f948a2c4496c2 (diff) | |
download | nextcloud-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.php | 16 |
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); |