Skip to content

Commit

Permalink
fix: psalm
Browse files Browse the repository at this point in the history
  • Loading branch information
solracsf committed Oct 17, 2024
1 parent 955aa2e commit bca87e5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
2 changes: 1 addition & 1 deletion apps/dav/lib/CalDAV/Reminder/Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Backend {
*/
public function __construct(
protected IDBConnection $db,
protectedITimeFactory $timeFactory,
protected ITimeFactory $timeFactory,
) {
}

Expand Down
9 changes: 2 additions & 7 deletions apps/files_sharing/lib/ShareBackend/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
use OC\Files\View;
use OCA\FederatedFileSharing\FederatedShareProvider;
use OCA\Files_Sharing\Helper;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Files\NotFoundException;
use OCP\IDBConnection;
use OCP\Server;
use OCP\Share\IShare;
use OCP\Share_Backend_File_Dependent;
Expand All @@ -29,10 +27,7 @@ class File implements Share_Backend_File_Dependent {

private $path;

public function __construct(
private ?FederatedShareProvider $federatedShareProvider = null,
protected IDBConnection $connection,
) {
public function __construct(private ?FederatedShareProvider $federatedShareProvider = null) {
if ($federatedShareProvider) {
$this->federatedShareProvider = $federatedShareProvider;
} else {
Expand Down Expand Up @@ -185,7 +180,7 @@ protected static function resolveReshares($source) {
if (isset($source['parent'])) {
$parent = $source['parent'];
while (isset($parent)) {
$qb = $this->connection->getQueryBuilder();
$qb = \OC::$server->getDatabaseConnection()->getQueryBuilder();
$qb->select('parent', 'uid_owner')
->from('share')
->where(
Expand Down
22 changes: 10 additions & 12 deletions lib/private/Files/Cache/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ public static function getGlobalCache() {
* @param bool $isAvailable
* @throws \RuntimeException
*/
public function __construct(
$storage,
$isAvailable,
protected IDBConnection $connection,
) {
public function __construct($storage, $isAvailable, IDBConnection $connection) {
if ($storage instanceof IStorage) {
$this->storageId = $storage->getId();
} else {
Expand Down Expand Up @@ -156,12 +152,12 @@ public function setAvailability($isAvailable, int $delay = 0) {
\OCP\Server::get(LoggerInterface::class)->info('Storage with ' . $this->storageId . ' marked as unavailable', ['app' => 'lib']);
}

$query = $this->connection->getQueryBuilder();
$query = \OC::$server->getDatabaseConnection()->getQueryBuilder();
$query->update('storages')
->set('available', $query->createNamedParameter($available))
->set('last_checked', $query->createNamedParameter(time() + $delay))
->where($query->expr()->eq('id', $query->createNamedParameter($this->storageId)));
$query->executeStatement();
$query->executeQuery();
}

/**
Expand All @@ -183,13 +179,13 @@ public static function remove($storageId) {
$storageId = self::adjustStorageId($storageId);
$numericId = self::getNumericStorageId($storageId);

$query = $this->connection->getQueryBuilder();
$query = \OC::$server->getDatabaseConnection()->getQueryBuilder();
$query->delete('storages')
->where($query->expr()->eq('id', $query->createNamedParameter($storageId)));
$query->executeStatement();

if (!is_null($numericId)) {
$query = $this->connection->getQueryBuilder();
$query = \OC::$server->getDatabaseConnection()->getQueryBuilder();
$query->delete('filecache')
->where($query->expr()->eq('storage', $query->createNamedParameter($numericId)));
$query->executeStatement();
Expand All @@ -202,10 +198,12 @@ public static function remove($storageId) {
* @param int $mountId
*/
public static function cleanByMountId(int $mountId) {
$db = \OC::$server->getDatabaseConnection();

try {
$this->connection->beginTransaction();
$db->beginTransaction();

$query = $this->connection->getQueryBuilder();
$query = $db->getQueryBuilder();
$query->select('storage_id')
->from('mounts')
->where($query->expr()->eq('mount_id', $query->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)));
Expand All @@ -227,7 +225,7 @@ public static function cleanByMountId(int $mountId) {
->where($query->expr()->eq('mount_id', $query->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)));
$query->executeStatement();

$this->connection->commit();
$db->commit();
} catch (\Exception $e) {
$db->rollBack();
throw $e;
Expand Down

0 comments on commit bca87e5

Please sign in to comment.