diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2013-02-26 07:34:46 -0800 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2013-02-26 07:34:46 -0800 |
commit | 81c664697b810d591b6b106bce7fde707c465e8f (patch) | |
tree | 65b6498123237fd193d667fdc4b492922eab5861 /lib | |
parent | a148e6de40edc388773346645ff7b02ecc92329b (diff) | |
parent | ea841e5e15959b224b85c748f1d82abd54bf2e95 (diff) | |
download | nextcloud-server-81c664697b810d591b6b106bce7fde707c465e8f.tar.gz nextcloud-server-81c664697b810d591b6b106bce7fde707c465e8f.zip |
Merge pull request #1920 from owncloud/catch_vcategories_exceptions
Catch exceptions on malformed categories.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/vcategories.php | 52 |
1 files changed, 34 insertions, 18 deletions
diff --git a/lib/vcategories.php b/lib/vcategories.php index 8de497a6191..f94a0a55d3b 100644 --- a/lib/vcategories.php +++ b/lib/vcategories.php @@ -306,12 +306,18 @@ class OC_VCategories { OCP\Util::writeLog('core', __METHOD__.', name: ' . $name. ' exists already', OCP\Util::DEBUG); return false; } - OCP\DB::insertIfNotExist(self::CATEGORY_TABLE, - array( - 'uid' => $this->user, - 'type' => $this->type, - 'category' => $name, - )); + try { + OCP\DB::insertIfNotExist(self::CATEGORY_TABLE, + array( + 'uid' => $this->user, + 'type' => $this->type, + 'category' => $name, + )); + } catch(Exception $e) { + OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(), + OCP\Util::ERROR); + return false; + } $id = OCP\DB::insertid(self::CATEGORY_TABLE); OCP\Util::writeLog('core', __METHOD__.', id: ' . $id, OCP\Util::DEBUG); $this->categories[$id] = $name; @@ -436,12 +442,17 @@ class OC_VCategories { private function save() { if(is_array($this->categories)) { foreach($this->categories as $category) { - OCP\DB::insertIfNotExist(self::CATEGORY_TABLE, - array( - 'uid' => $this->user, - 'type' => $this->type, - 'category' => $category, - )); + try { + OCP\DB::insertIfNotExist(self::CATEGORY_TABLE, + array( + 'uid' => $this->user, + 'type' => $this->type, + 'category' => $category, + )); + } catch(Exception $e) { + OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(), + OCP\Util::ERROR); + } } // reload categories to get the proper ids. $this->loadCategories(); @@ -454,12 +465,17 @@ class OC_VCategories { $catid = $this->array_searchi($relation['category'], $categories); OC_Log::write('core', __METHOD__ . 'catid, ' . $relation['category'] . ' ' . $catid, OC_Log::DEBUG); if($catid) { - OCP\DB::insertIfNotExist(self::RELATION_TABLE, - array( - 'objid' => $relation['objid'], - 'categoryid' => $catid, - 'type' => $this->type, - )); + try { + OCP\DB::insertIfNotExist(self::RELATION_TABLE, + array( + 'objid' => $relation['objid'], + 'categoryid' => $catid, + 'type' => $this->type, + )); + } catch(Exception $e) { + OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(), + OCP\Util::ERROR); + } } } self::$relations = array(); // reset |