Code Duplication    Length = 7-10 lines in 12 locations

lib/private/Authentication/Token/DefaultTokenMapper.php 1 location

@@ 117-124 (lines=8) @@
114
	 * @param IUser $user
115
	 * @param int $id
116
	 */
117
	public function deleteById(IUser $user, $id) {
118
		/* @var $qb IQueryBuilder */
119
		$qb = $this->db->getQueryBuilder();
120
		$qb->delete('authtoken')
121
			->where($qb->expr()->eq('id', $qb->createNamedParameter($id)))
122
			->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())));
123
		$qb->execute();
124
	}
125
}
126

lib/private/Files/External/Service/DBConfigService.php 2 locations

@@ 243-251 (lines=9) @@
240
	 * @param int $mountId
241
	 * @param string $newMountPoint
242
	 */
243
	public function setMountPoint($mountId, $newMountPoint) {
244
		$builder = $this->connection->getQueryBuilder();
245
246
		$query = $builder->update('external_mounts')
247
			->set('mount_point', $builder->createNamedParameter($newMountPoint))
248
			->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)));
249
250
		$query->execute();
251
	}
252
253
	/**
254
	 * @param int $mountId
@@ 257-265 (lines=9) @@
254
	 * @param int $mountId
255
	 * @param string $newAuthBackend
256
	 */
257
	public function setAuthBackend($mountId, $newAuthBackend) {
258
		$builder = $this->connection->getQueryBuilder();
259
260
		$query = $builder->update('external_mounts')
261
			->set('auth_backend', $builder->createNamedParameter($newAuthBackend))
262
			->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)));
263
264
		$query->execute();
265
	}
266
267
	/**
268
	 * @param int $mountId

lib/private/BackgroundJob/JobList.php 2 locations

@@ 287-293 (lines=7) @@
284
	 *
285
	 * @param IJob $job
286
	 */
287
	public function unlockJob($job) {
288
		$query = $this->connection->getQueryBuilder();
289
		$query->update('jobs')
290
			->set('reserved_at', $query->expr()->literal(0, IQueryBuilder::PARAM_INT))
291
			->where($query->expr()->eq('id', $query->createNamedParameter($job->getId(), IQueryBuilder::PARAM_INT)));
292
		$query->execute();
293
	}
294
295
	/**
296
	 * get the id of the last ran job
@@ 318-324 (lines=7) @@
315
		$query->execute();
316
	}
317
318
	public function setExecutionTime($job, $timeTaken) {
319
		$query = $this->connection->getQueryBuilder();
320
		$query->update('jobs')
321
			->set('execution_duration', $query->createNamedParameter($timeTaken, IQueryBuilder::PARAM_INT))
322
			->where($query->expr()->eq('id', $query->createNamedParameter($job->getId(), IQueryBuilder::PARAM_INT)));
323
		$query->execute();
324
	}
325
326
	/**
327
	 * @inheritdoc

apps/federation/lib/DbHandler.php 1 location

@@ 98-104 (lines=7) @@
95
	 *
96
	 * @param int $id
97
	 */
98
	public function removeServer($id) {
99
		$query = $this->connection->getQueryBuilder();
100
		$query->delete($this->dbTable)
101
			->where($query->expr()->eq('id', $query->createParameter('id')))
102
			->setParameter('id', $id);
103
		$query->execute();
104
	}
105
106
	/**
107
	 * get trusted server with given ID

lib/private/Files/Config/UserMountCache.php 2 locations

@@ 301-307 (lines=7) @@
298
	 *
299
	 * @param IUser $user
300
	 */
301
	public function removeUserMounts(IUser $user) {
302
		$builder = $this->connection->getQueryBuilder();
303
304
		$query = $builder->delete('mounts')
305
			->where($builder->expr()->eq('user_id', $builder->createNamedParameter($user->getUID())));
306
		$query->execute();
307
	}
308
309
	public function removeUserStorageMount($storageId, $userId) {
310
		$builder = $this->connection->getQueryBuilder();
@@ 318-324 (lines=7) @@
315
		$query->execute();
316
	}
317
318
	public function remoteStorageMounts($storageId) {
319
		$builder = $this->connection->getQueryBuilder();
320
321
		$query = $builder->delete('mounts')
322
			->where($builder->expr()->eq('storage_id', $builder->createNamedParameter($storageId, IQueryBuilder::PARAM_INT)));
323
		$query->execute();
324
	}
325
}
326

apps/federatedfilesharing/lib/FederatedShareProvider.php 3 locations

@@ 386-392 (lines=7) @@
383
	 * @param int $shareId
384
	 * @param string $token
385
	 */
386
	protected function updateSuccessfulReShare($shareId, $token) {
387
		$query = $this->dbConnection->getQueryBuilder();
388
		$query->update($this->shareTable)
389
			->where($query->expr()->eq('id', $query->createNamedParameter($shareId)))
390
			->set('token', $query->createNamedParameter($token))
391
			->execute();
392
	}
393
394
	/**
395
	 * store remote ID in federated reShare table
@@ 539-548 (lines=10) @@
536
	 *
537
	 * @param string $shareId
538
	 */
539
	private function removeShareFromTableById($shareId) {
540
		$qb = $this->dbConnection->getQueryBuilder();
541
		$qb->delete($this->shareTable)
542
			->where($qb->expr()->eq('id', $qb->createNamedParameter($shareId)));
543
		$qb->execute();
544
545
		$qb->delete('federated_reshares')
546
			->where($qb->expr()->eq('share_id', $qb->createNamedParameter($shareId)));
547
		$qb->execute();
548
	}
549
550
	/**
551
	 * @inheritdoc
@@ 900-909 (lines=10) @@
897
	 * @param string $uid
898
	 * @param int $shareType
899
	 */
900
	public function userDeleted($uid, $shareType) {
901
		//TODO: probabaly a good idea to send unshare info to remote servers
902
903
		$qb = $this->dbConnection->getQueryBuilder();
904
905
		$qb->delete($this->shareTable)
906
			->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_REMOTE)))
907
			->andWhere($qb->expr()->eq('uid_owner', $qb->createNamedParameter($uid)))
908
			->execute();
909
	}
910
911
	/**
912
	 * This provider does not handle groups

lib/private/Lock/Persistent/LockMapper.php 1 location

@@ 92-101 (lines=10) @@
89
	 * @param string $token
90
	 * @return bool
91
	 */
92
	public function deleteByFileIdAndToken(int $fileId, string $token) : bool {
93
		$query = $this->db->getQueryBuilder();
94
95
		$rowCount = $query->delete($this->getTableName())
96
			->where($query->expr()->eq('file_id', $query->createNamedParameter($fileId)))
97
			->andWhere($query->expr()->eq('token_hash', $query->createNamedParameter(\md5($token))))
98
			->execute();
99
100
		return $rowCount === 1;
101
	}
102
103
	/**
104
	 * @param string $token