summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2013-04-06 09:48:03 -0700
committerBart Visscher <bartv@thisnet.nl>2013-04-06 09:48:03 -0700
commita8b366e6128fe81490a7488e594d51dcddeede8b (patch)
tree4d0698611db99939b368ae45720cb7c2fe7fb114
parent46a552fd561f676a4cf7a70ae71ffbd4e9473d9a (diff)
parentd048ff719db224e145783c77d2f3b50c03eb30a0 (diff)
downloadnextcloud-server-a8b366e6128fe81490a7488e594d51dcddeede8b.tar.gz
nextcloud-server-a8b366e6128fe81490a7488e594d51dcddeede8b.zip
Merge pull request #2610 from owncloud/vcategories_purge_multi
Allow purging multiple objects from category index table.
-rw-r--r--lib/vcategories.php20
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/vcategories.php b/lib/vcategories.php
index 2f990c5d2d2..5975e688b75 100644
--- a/lib/vcategories.php
+++ b/lib/vcategories.php
@@ -536,23 +536,31 @@ class OC_VCategories {
/**
* @brief Delete category/object relations from the db
- * @param int $id The id of the object
+ * @param array $ids The ids of the objects
* @param string $type The type of object (event/contact/task/journal).
* Defaults to the type set in the instance
* @returns boolean Returns false on error.
*/
- public function purgeObject($id, $type = null) {
+ public function purgeObjects(array $ids, $type = null) {
$type = is_null($type) ? $this->type : $type;
+ if(count($ids) === 0) {
+ // job done ;)
+ return true;
+ }
+ $updates = $ids;
try {
- $stmt = OCP\DB::prepare('DELETE FROM `' . self::RELATION_TABLE . '` '
- . 'WHERE `objid` = ? AND `type`= ?');
- $result = $stmt->execute(array($id, $type));
+ $query = 'DELETE FROM `' . self::RELATION_TABLE . '` ';
+ $query .= 'WHERE `objid` IN (' . str_repeat('?,', count($ids)-1) . '?) ';
+ $query .= 'AND `type`= ?';
+ $updates[] = $type;
+ $stmt = OCP\DB::prepare($query);
+ $result = $stmt->execute($updates);
if (OC_DB::isError($result)) {
OC_Log::write('core', __METHOD__. 'DB error: ' . OC_DB::getErrorMessage($result), OC_Log::ERROR);
return false;
}
} catch(Exception $e) {
- OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
+ OCP\Util::writeLog('core', __METHOD__.', exception: ' . $e->getMessage(),
OCP\Util::ERROR);
return false;
}