Cleanp execute usage in the trashbin

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2021-03-11 15:39:42 +01:00
parent 69c4578b5b
commit 8008b33b8d
1 changed files with 9 additions and 9 deletions

View File

@ -133,7 +133,7 @@ class Trashbin {
$query->select('id', 'timestamp', 'location') $query->select('id', 'timestamp', 'location')
->from('files_trash') ->from('files_trash')
->where($query->expr()->eq('user', $query->createNamedParameter($user))); ->where($query->expr()->eq('user', $query->createNamedParameter($user)));
$result = $query->execute(); $result = $query->executeQuery();
$array = []; $array = [];
while ($row = $result->fetch()) { while ($row = $result->fetch()) {
if (isset($array[$row['id']])) { if (isset($array[$row['id']])) {
@ -162,7 +162,7 @@ class Trashbin {
->andWhere($query->expr()->eq('id', $query->createNamedParameter($filename))) ->andWhere($query->expr()->eq('id', $query->createNamedParameter($filename)))
->andWhere($query->expr()->eq('timestamp', $query->createNamedParameter($timestamp))); ->andWhere($query->expr()->eq('timestamp', $query->createNamedParameter($timestamp)));
$result = $query->execute(); $result = $query->executeQuery();
$row = $result->fetch(); $row = $result->fetch();
$result->closeCursor(); $result->closeCursor();
@ -226,7 +226,7 @@ class Trashbin {
->setValue('timestamp', $query->createNamedParameter($timestamp)) ->setValue('timestamp', $query->createNamedParameter($timestamp))
->setValue('location', $query->createNamedParameter($targetLocation)) ->setValue('location', $query->createNamedParameter($targetLocation))
->setValue('user', $query->createNamedParameter($user)); ->setValue('user', $query->createNamedParameter($user));
$result = $query->execute(); $result = $query->executeUpdate();
if (!$result) { if (!$result) {
\OC::$server->getLogger()->error('trash bin database couldn\'t be updated for the files owner', ['app' => 'files_trashbin']); \OC::$server->getLogger()->error('trash bin database couldn\'t be updated for the files owner', ['app' => 'files_trashbin']);
} }
@ -353,7 +353,7 @@ class Trashbin {
->setValue('timestamp', $query->createNamedParameter($timestamp)) ->setValue('timestamp', $query->createNamedParameter($timestamp))
->setValue('location', $query->createNamedParameter($location)) ->setValue('location', $query->createNamedParameter($location))
->setValue('user', $query->createNamedParameter($owner)); ->setValue('user', $query->createNamedParameter($owner));
$result = $query->execute(); $result = $query->executeUpdate();
if (!$result) { if (!$result) {
\OC::$server->getLogger()->error('trash bin database couldn\'t be updated', ['app' => 'files_trashbin']); \OC::$server->getLogger()->error('trash bin database couldn\'t be updated', ['app' => 'files_trashbin']);
} }
@ -516,7 +516,7 @@ class Trashbin {
->where($query->expr()->eq('user', $query->createNamedParameter($user))) ->where($query->expr()->eq('user', $query->createNamedParameter($user)))
->andWhere($query->expr()->eq('id', $query->createNamedParameter($filename))) ->andWhere($query->expr()->eq('id', $query->createNamedParameter($filename)))
->andWhere($query->expr()->eq('timestamp', $query->createNamedParameter($timestamp))); ->andWhere($query->expr()->eq('timestamp', $query->createNamedParameter($timestamp)));
$query->execute(); $query->executeUpdate();
} }
return true; return true;
@ -606,7 +606,7 @@ class Trashbin {
$query = \OC::$server->getDatabaseConnection()->getQueryBuilder(); $query = \OC::$server->getDatabaseConnection()->getQueryBuilder();
$query->delete('files_trash') $query->delete('files_trash')
->where($query->expr()->eq('user', $query->createNamedParameter($user))); ->where($query->expr()->eq('user', $query->createNamedParameter($user)));
$query->execute(); $query->executeUpdate();
// Bulk PostDelete-Hook // Bulk PostDelete-Hook
\OC_Hook::emit('\OCP\Trashbin', 'deleteAll', ['paths' => $filePaths]); \OC_Hook::emit('\OCP\Trashbin', 'deleteAll', ['paths' => $filePaths]);
@ -660,7 +660,7 @@ class Trashbin {
->where($query->expr()->eq('user', $query->createNamedParameter($user))) ->where($query->expr()->eq('user', $query->createNamedParameter($user)))
->andWhere($query->expr()->eq('id', $query->createNamedParameter($filename))) ->andWhere($query->expr()->eq('id', $query->createNamedParameter($filename)))
->andWhere($query->expr()->eq('timestamp', $query->createNamedParameter($timestamp))); ->andWhere($query->expr()->eq('timestamp', $query->createNamedParameter($timestamp)));
$query->execute(); $query->executeUpdate();
$file = $filename . '.d' . $timestamp; $file = $filename . '.d' . $timestamp;
} else { } else {
@ -746,7 +746,7 @@ class Trashbin {
$query = \OC::$server->getDatabaseConnection()->getQueryBuilder(); $query = \OC::$server->getDatabaseConnection()->getQueryBuilder();
$query->delete('files_trash') $query->delete('files_trash')
->where($query->expr()->eq('user', $query->createNamedParameter($uid))); ->where($query->expr()->eq('user', $query->createNamedParameter($uid)));
return (bool) $query->execute(); return (bool) $query->executeUpdate();
} }
/** /**
@ -1003,7 +1003,7 @@ class Trashbin {
->andWhere($query->expr()->eq('parent', $query->createNamedParameter($parentId))) ->andWhere($query->expr()->eq('parent', $query->createNamedParameter($parentId)))
->andWhere($query->expr()->iLike('name', $query->createNamedParameter($pattern))); ->andWhere($query->expr()->iLike('name', $query->createNamedParameter($pattern)));
$result = $query->execute(); $result = $query->executeQuery();
$entries = $result->fetchAll(); $entries = $result->fetchAll();
$result->closeCursor(); $result->closeCursor();