Completed
Push — master ( 034246...d4e9a8 )
by
unknown
19:42 queued 13s
created
apps/workflowengine/lib/Migration/Version2200Date20210805101925.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -32,23 +32,23 @@
 block discarded – undo
32 32
 
33 33
 class Version2200Date20210805101925 extends SimpleMigrationStep {
34 34
 
35
-	/**
36
-	 * @param IOutput $output
37
-	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
38
-	 * @param array $options
39
-	 * @return null|ISchemaWrapper
40
-	 */
41
-	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
42
-		/** @var ISchemaWrapper $schema */
43
-		$schema = $schemaClosure();
35
+    /**
36
+     * @param IOutput $output
37
+     * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
38
+     * @param array $options
39
+     * @return null|ISchemaWrapper
40
+     */
41
+    public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
42
+        /** @var ISchemaWrapper $schema */
43
+        $schema = $schemaClosure();
44 44
 
45
-		if ($schema->hasTable('flow_operations')) {
46
-			$table = $schema->getTable('flow_operations');
47
-			$table->changeColumn('name', [
48
-				'notnull' => false,
49
-			]);
50
-		}
45
+        if ($schema->hasTable('flow_operations')) {
46
+            $table = $schema->getTable('flow_operations');
47
+            $table->changeColumn('name', [
48
+                'notnull' => false,
49
+            ]);
50
+        }
51 51
 
52
-		return $schema;
53
-	}
52
+        return $schema;
53
+    }
54 54
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Migration/Version1015Date20211104103506.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -59,19 +59,19 @@
 block discarded – undo
59 59
 		}
60 60
 
61 61
 		while ($mount = $mounts->fetch()) {
62
-			$config = $this->getStorageConfig((int)$mount['mount_id']);
62
+			$config = $this->getStorageConfig((int) $mount['mount_id']);
63 63
 			$hostname = $config['hostname'];
64 64
 			$bucket = $config['bucket'];
65 65
 			$key = $config['key'];
66
-			$oldId = Storage::adjustStorageId('amazon::' . $bucket);
67
-			$newId = Storage::adjustStorageId('amazon::external::' . md5($hostname . ':' . $bucket . ':' . $key));
66
+			$oldId = Storage::adjustStorageId('amazon::'.$bucket);
67
+			$newId = Storage::adjustStorageId('amazon::external::'.md5($hostname.':'.$bucket.':'.$key));
68 68
 			try {
69 69
 				$qb->setParameter('oldId', $oldId);
70 70
 				$qb->setParameter('newId', $newId);
71 71
 				$qb->execute();
72
-				$this->logger->info('Migrated s3 storage id for mount with id ' . $mount['mount_id'] . ' to ' . $newId);
72
+				$this->logger->info('Migrated s3 storage id for mount with id '.$mount['mount_id'].' to '.$newId);
73 73
 			} catch (Exception $e) {
74
-				$this->logger->error('Failed to migrate external s3 storage id for mount with id ' . $mount['mount_id'], [
74
+				$this->logger->error('Failed to migrate external s3 storage id for mount with id '.$mount['mount_id'], [
75 75
 					'exception' => $e
76 76
 				]);
77 77
 			}
Please login to merge, or discard this patch.
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -20,71 +20,71 @@
 block discarded – undo
20 20
 
21 21
 class Version1015Date20211104103506 extends SimpleMigrationStep {
22 22
 
23
-	public function __construct(
24
-		private IDBConnection $connection,
25
-		private LoggerInterface $logger,
26
-	) {
27
-	}
23
+    public function __construct(
24
+        private IDBConnection $connection,
25
+        private LoggerInterface $logger,
26
+    ) {
27
+    }
28 28
 
29
-	public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
30
-		$qb = $this->connection->getQueryBuilder();
31
-		$qb->update('storages')
32
-			->set('id', $qb->createParameter('newId'))
33
-			->where($qb->expr()->eq('id', $qb->createParameter('oldId')));
29
+    public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
30
+        $qb = $this->connection->getQueryBuilder();
31
+        $qb->update('storages')
32
+            ->set('id', $qb->createParameter('newId'))
33
+            ->where($qb->expr()->eq('id', $qb->createParameter('oldId')));
34 34
 
35
-		$mounts = $this->getS3Mounts();
36
-		if (!$mounts instanceof IResult) {
37
-			throw new \Exception('Could not fetch existing mounts for migration');
38
-		}
35
+        $mounts = $this->getS3Mounts();
36
+        if (!$mounts instanceof IResult) {
37
+            throw new \Exception('Could not fetch existing mounts for migration');
38
+        }
39 39
 
40
-		while ($mount = $mounts->fetch()) {
41
-			$config = $this->getStorageConfig((int)$mount['mount_id']);
42
-			$hostname = $config['hostname'];
43
-			$bucket = $config['bucket'];
44
-			$key = $config['key'];
45
-			$oldId = Storage::adjustStorageId('amazon::' . $bucket);
46
-			$newId = Storage::adjustStorageId('amazon::external::' . md5($hostname . ':' . $bucket . ':' . $key));
47
-			try {
48
-				$qb->setParameter('oldId', $oldId);
49
-				$qb->setParameter('newId', $newId);
50
-				$qb->execute();
51
-				$this->logger->info('Migrated s3 storage id for mount with id ' . $mount['mount_id'] . ' to ' . $newId);
52
-			} catch (Exception $e) {
53
-				$this->logger->error('Failed to migrate external s3 storage id for mount with id ' . $mount['mount_id'], [
54
-					'exception' => $e
55
-				]);
56
-			}
57
-		}
58
-		return null;
59
-	}
40
+        while ($mount = $mounts->fetch()) {
41
+            $config = $this->getStorageConfig((int)$mount['mount_id']);
42
+            $hostname = $config['hostname'];
43
+            $bucket = $config['bucket'];
44
+            $key = $config['key'];
45
+            $oldId = Storage::adjustStorageId('amazon::' . $bucket);
46
+            $newId = Storage::adjustStorageId('amazon::external::' . md5($hostname . ':' . $bucket . ':' . $key));
47
+            try {
48
+                $qb->setParameter('oldId', $oldId);
49
+                $qb->setParameter('newId', $newId);
50
+                $qb->execute();
51
+                $this->logger->info('Migrated s3 storage id for mount with id ' . $mount['mount_id'] . ' to ' . $newId);
52
+            } catch (Exception $e) {
53
+                $this->logger->error('Failed to migrate external s3 storage id for mount with id ' . $mount['mount_id'], [
54
+                    'exception' => $e
55
+                ]);
56
+            }
57
+        }
58
+        return null;
59
+    }
60 60
 
61
-	/**
62
-	 * @throws Exception
63
-	 * @return IResult|int
64
-	 */
65
-	private function getS3Mounts() {
66
-		$qb = $this->connection->getQueryBuilder();
67
-		$qb->select('m.mount_id')
68
-			->selectAlias('c.value', 'bucket')
69
-			->from('external_mounts', 'm')
70
-			->innerJoin('m', 'external_config', 'c', 'c.mount_id = m.mount_id')
71
-			->where($qb->expr()->eq('m.storage_backend', $qb->createPositionalParameter('amazons3')))
72
-			->andWhere($qb->expr()->eq('c.key', $qb->createPositionalParameter('bucket')));
73
-		return $qb->execute();
74
-	}
61
+    /**
62
+     * @throws Exception
63
+     * @return IResult|int
64
+     */
65
+    private function getS3Mounts() {
66
+        $qb = $this->connection->getQueryBuilder();
67
+        $qb->select('m.mount_id')
68
+            ->selectAlias('c.value', 'bucket')
69
+            ->from('external_mounts', 'm')
70
+            ->innerJoin('m', 'external_config', 'c', 'c.mount_id = m.mount_id')
71
+            ->where($qb->expr()->eq('m.storage_backend', $qb->createPositionalParameter('amazons3')))
72
+            ->andWhere($qb->expr()->eq('c.key', $qb->createPositionalParameter('bucket')));
73
+        return $qb->execute();
74
+    }
75 75
 
76
-	/**
77
-	 * @throws Exception
78
-	 */
79
-	private function getStorageConfig(int $mountId): array {
80
-		$qb = $this->connection->getQueryBuilder();
81
-		$qb->select('key', 'value')
82
-			->from('external_config')
83
-			->where($qb->expr()->eq('mount_id', $qb->createPositionalParameter($mountId)));
84
-		$config = [];
85
-		foreach ($qb->execute()->fetchAll() as $row) {
86
-			$config[$row['key']] = $row['value'];
87
-		}
88
-		return $config;
89
-	}
76
+    /**
77
+     * @throws Exception
78
+     */
79
+    private function getStorageConfig(int $mountId): array {
80
+        $qb = $this->connection->getQueryBuilder();
81
+        $qb->select('key', 'value')
82
+            ->from('external_config')
83
+            ->where($qb->expr()->eq('mount_id', $qb->createPositionalParameter($mountId)));
84
+        $config = [];
85
+        foreach ($qb->execute()->fetchAll() as $row) {
86
+            $config[$row['key']] = $row['value'];
87
+        }
88
+        return $config;
89
+    }
90 90
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/MtimeSanitizer.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -23,20 +23,20 @@
 block discarded – undo
23 23
 namespace OCA\DAV\Connector\Sabre;
24 24
 
25 25
 class MtimeSanitizer {
26
-	public static function sanitizeMtime(string $mtimeFromRequest): int {
27
-		// In PHP 5.X "is_numeric" returns true for strings in hexadecimal
28
-		// notation. This is no longer the case in PHP 7.X, so this check
29
-		// ensures that strings with hexadecimal notations fail too in PHP 5.X.
30
-		$isHexadecimal = preg_match('/^\s*0[xX]/', $mtimeFromRequest);
31
-		if ($isHexadecimal || !is_numeric($mtimeFromRequest)) {
32
-			throw new \InvalidArgumentException('X-OC-MTime header must be an integer (unix timestamp).');
33
-		}
26
+    public static function sanitizeMtime(string $mtimeFromRequest): int {
27
+        // In PHP 5.X "is_numeric" returns true for strings in hexadecimal
28
+        // notation. This is no longer the case in PHP 7.X, so this check
29
+        // ensures that strings with hexadecimal notations fail too in PHP 5.X.
30
+        $isHexadecimal = preg_match('/^\s*0[xX]/', $mtimeFromRequest);
31
+        if ($isHexadecimal || !is_numeric($mtimeFromRequest)) {
32
+            throw new \InvalidArgumentException('X-OC-MTime header must be an integer (unix timestamp).');
33
+        }
34 34
 
35
-		// Prevent writing invalid mtime (timezone-proof)
36
-		if ((int)$mtimeFromRequest <= 24 * 60 * 60) {
37
-			throw new \InvalidArgumentException('X-OC-MTime header must be a valid positive integer');
38
-		}
35
+        // Prevent writing invalid mtime (timezone-proof)
36
+        if ((int)$mtimeFromRequest <= 24 * 60 * 60) {
37
+            throw new \InvalidArgumentException('X-OC-MTime header must be a valid positive integer');
38
+        }
39 39
 
40
-		return (int)$mtimeFromRequest;
41
-	}
40
+        return (int)$mtimeFromRequest;
41
+    }
42 42
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,10 +33,10 @@
 block discarded – undo
33 33
 		}
34 34
 
35 35
 		// Prevent writing invalid mtime (timezone-proof)
36
-		if ((int)$mtimeFromRequest <= 24 * 60 * 60) {
36
+		if ((int) $mtimeFromRequest <= 24 * 60 * 60) {
37 37
 			throw new \InvalidArgumentException('X-OC-MTime header must be a valid positive integer');
38 38
 		}
39 39
 
40
-		return (int)$mtimeFromRequest;
40
+		return (int) $mtimeFromRequest;
41 41
 	}
42 42
 }
Please login to merge, or discard this patch.
lib/private/Security/TrustedDomainHelper.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 		}
71 71
 
72 72
 		if (isset($parsedUrl['port']) && $parsedUrl['port']) {
73
-			return $this->isTrustedDomain($parsedUrl['host'] . ':' . $parsedUrl['port']);
73
+			return $this->isTrustedDomain($parsedUrl['host'].':'.$parsedUrl['port']);
74 74
 		}
75 75
 
76 76
 		return $this->isTrustedDomain($parsedUrl['host']);
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
 			if (gettype($trusted) !== 'string') {
107 107
 				break;
108 108
 			}
109
-			$regex = '/^' . implode('[-\.a-zA-Z0-9]*', array_map(function ($v) {
109
+			$regex = '/^'.implode('[-\.a-zA-Z0-9]*', array_map(function($v) {
110 110
 				return preg_quote($v, '/');
111
-			}, explode('*', $trusted))) . '$/i';
111
+			}, explode('*', $trusted))).'$/i';
112 112
 			if (preg_match($regex, $domain) || preg_match($regex, $domainWithPort)) {
113 113
 				return true;
114 114
 			}
Please login to merge, or discard this patch.
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -13,79 +13,79 @@
 block discarded – undo
13 13
 use OCP\Security\ITrustedDomainHelper;
14 14
 
15 15
 class TrustedDomainHelper implements ITrustedDomainHelper {
16
-	public function __construct(
17
-		private IConfig $config,
18
-	) {
19
-	}
16
+    public function __construct(
17
+        private IConfig $config,
18
+    ) {
19
+    }
20 20
 
21
-	/**
22
-	 * Strips a potential port from a domain (in format domain:port)
23
-	 * @return string $host without appended port
24
-	 */
25
-	private function getDomainWithoutPort(string $host): string {
26
-		$pos = strrpos($host, ':');
27
-		if ($pos !== false) {
28
-			$port = substr($host, $pos + 1);
29
-			if (is_numeric($port)) {
30
-				$host = substr($host, 0, $pos);
31
-			}
32
-		}
33
-		return $host;
34
-	}
21
+    /**
22
+     * Strips a potential port from a domain (in format domain:port)
23
+     * @return string $host without appended port
24
+     */
25
+    private function getDomainWithoutPort(string $host): string {
26
+        $pos = strrpos($host, ':');
27
+        if ($pos !== false) {
28
+            $port = substr($host, $pos + 1);
29
+            if (is_numeric($port)) {
30
+                $host = substr($host, 0, $pos);
31
+            }
32
+        }
33
+        return $host;
34
+    }
35 35
 
36
-	/**
37
-	 * {@inheritDoc}
38
-	 */
39
-	public function isTrustedUrl(string $url): bool {
40
-		$parsedUrl = parse_url($url);
41
-		if (empty($parsedUrl['host'])) {
42
-			return false;
43
-		}
36
+    /**
37
+     * {@inheritDoc}
38
+     */
39
+    public function isTrustedUrl(string $url): bool {
40
+        $parsedUrl = parse_url($url);
41
+        if (empty($parsedUrl['host'])) {
42
+            return false;
43
+        }
44 44
 
45
-		if (isset($parsedUrl['port']) && $parsedUrl['port']) {
46
-			return $this->isTrustedDomain($parsedUrl['host'] . ':' . $parsedUrl['port']);
47
-		}
45
+        if (isset($parsedUrl['port']) && $parsedUrl['port']) {
46
+            return $this->isTrustedDomain($parsedUrl['host'] . ':' . $parsedUrl['port']);
47
+        }
48 48
 
49
-		return $this->isTrustedDomain($parsedUrl['host']);
50
-	}
49
+        return $this->isTrustedDomain($parsedUrl['host']);
50
+    }
51 51
 
52
-	/**
53
-	 * {@inheritDoc}
54
-	 */
55
-	public function isTrustedDomain(string $domainWithPort): bool {
56
-		// overwritehost is always trusted
57
-		if ($this->config->getSystemValue('overwritehost') !== '') {
58
-			return true;
59
-		}
52
+    /**
53
+     * {@inheritDoc}
54
+     */
55
+    public function isTrustedDomain(string $domainWithPort): bool {
56
+        // overwritehost is always trusted
57
+        if ($this->config->getSystemValue('overwritehost') !== '') {
58
+            return true;
59
+        }
60 60
 
61
-		$domain = $this->getDomainWithoutPort($domainWithPort);
61
+        $domain = $this->getDomainWithoutPort($domainWithPort);
62 62
 
63
-		// Read trusted domains from config
64
-		$trustedList = $this->config->getSystemValue('trusted_domains', []);
65
-		if (!is_array($trustedList)) {
66
-			return false;
67
-		}
63
+        // Read trusted domains from config
64
+        $trustedList = $this->config->getSystemValue('trusted_domains', []);
65
+        if (!is_array($trustedList)) {
66
+            return false;
67
+        }
68 68
 
69
-		// Always allow access from localhost
70
-		if (preg_match(Request::REGEX_LOCALHOST, $domain) === 1) {
71
-			return true;
72
-		}
73
-		// Reject malformed domains in any case
74
-		if (str_starts_with($domain, '-') || str_contains($domain, '..')) {
75
-			return false;
76
-		}
77
-		// Match, allowing for * wildcards
78
-		foreach ($trustedList as $trusted) {
79
-			if (gettype($trusted) !== 'string') {
80
-				break;
81
-			}
82
-			$regex = '/^' . implode('[-\.a-zA-Z0-9]*', array_map(function ($v) {
83
-				return preg_quote($v, '/');
84
-			}, explode('*', $trusted))) . '$/i';
85
-			if (preg_match($regex, $domain) || preg_match($regex, $domainWithPort)) {
86
-				return true;
87
-			}
88
-		}
89
-		return false;
90
-	}
69
+        // Always allow access from localhost
70
+        if (preg_match(Request::REGEX_LOCALHOST, $domain) === 1) {
71
+            return true;
72
+        }
73
+        // Reject malformed domains in any case
74
+        if (str_starts_with($domain, '-') || str_contains($domain, '..')) {
75
+            return false;
76
+        }
77
+        // Match, allowing for * wildcards
78
+        foreach ($trustedList as $trusted) {
79
+            if (gettype($trusted) !== 'string') {
80
+                break;
81
+            }
82
+            $regex = '/^' . implode('[-\.a-zA-Z0-9]*', array_map(function ($v) {
83
+                return preg_quote($v, '/');
84
+            }, explode('*', $trusted))) . '$/i';
85
+            if (preg_match($regex, $domain) || preg_match($regex, $domainWithPort)) {
86
+                return true;
87
+            }
88
+        }
89
+        return false;
90
+    }
91 91
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/Migration/Version1130Date20220110154719.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -32,25 +32,25 @@
 block discarded – undo
32 32
 use OCP\Migration\SimpleMigrationStep;
33 33
 
34 34
 class Version1130Date20220110154719 extends SimpleMigrationStep {
35
-	public function getName() {
36
-		return 'Drop ldap_group_mapping_backup';
37
-	}
38
-
39
-	/**
40
-	 * @param IOutput $output
41
-	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
42
-	 * @param array $options
43
-	 * @return null|ISchemaWrapper
44
-	 */
45
-	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
46
-		/** @var ISchemaWrapper $schema */
47
-		$schema = $schemaClosure();
48
-
49
-		if ($schema->hasTable('ldap_group_mapping_backup')) {
50
-			$schema->dropTable('ldap_group_mapping_backup');
51
-			return $schema;
52
-		}
53
-
54
-		return null;
55
-	}
35
+    public function getName() {
36
+        return 'Drop ldap_group_mapping_backup';
37
+    }
38
+
39
+    /**
40
+     * @param IOutput $output
41
+     * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
42
+     * @param array $options
43
+     * @return null|ISchemaWrapper
44
+     */
45
+    public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
46
+        /** @var ISchemaWrapper $schema */
47
+        $schema = $schemaClosure();
48
+
49
+        if ($schema->hasTable('ldap_group_mapping_backup')) {
50
+            $schema->dropTable('ldap_group_mapping_backup');
51
+            return $schema;
52
+        }
53
+
54
+        return null;
55
+    }
56 56
 }
Please login to merge, or discard this patch.
apps/testing/lib/Controller/LockingController.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	 */
95 95
 	protected function getPath(string $user, string $path): string {
96 96
 		$node = $this->rootFolder->getUserFolder($user)->get($path);
97
-		return 'files/' . md5($node->getStorage()->getId() . '::' . trim($node->getInternalPath(), '/'));
97
+		return 'files/'.md5($node->getStorage()->getId().'::'.trim($node->getInternalPath(), '/'));
98 98
 	}
99 99
 
100 100
 	/**
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 
126 126
 		try {
127 127
 			$lockingProvider->acquireLock($path, $type);
128
-			$this->config->setAppValue('testing', 'locking_' . $path, (string)$type);
128
+			$this->config->setAppValue('testing', 'locking_'.$path, (string) $type);
129 129
 			return new DataResponse();
130 130
 		} catch (LockedException $e) {
131 131
 			throw new OCSException('', Http::STATUS_LOCKED, $e);
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 
149 149
 		try {
150 150
 			$lockingProvider->changeLock($path, $type);
151
-			$this->config->setAppValue('testing', 'locking_' . $path, (string)$type);
151
+			$this->config->setAppValue('testing', 'locking_'.$path, (string) $type);
152 152
 			return new DataResponse();
153 153
 		} catch (LockedException $e) {
154 154
 			throw new OCSException('', Http::STATUS_LOCKED, $e);
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 
172 172
 		try {
173 173
 			$lockingProvider->releaseLock($path, $type);
174
-			$this->config->deleteAppValue('testing', 'locking_' . $path);
174
+			$this->config->deleteAppValue('testing', 'locking_'.$path);
175 175
 			return new DataResponse();
176 176
 		} catch (LockedException $e) {
177 177
 			throw new OCSException('', Http::STATUS_LOCKED, $e);
@@ -206,12 +206,12 @@  discard block
 block discarded – undo
206 206
 			if (strpos($lock, 'locking_') === 0) {
207 207
 				$path = substr($lock, strlen('locking_'));
208 208
 
209
-				if ($type === ILockingProvider::LOCK_EXCLUSIVE && (int)$this->config->getAppValue('testing', $lock) === ILockingProvider::LOCK_EXCLUSIVE) {
210
-					$lockingProvider->releaseLock($path, (int)$this->config->getAppValue('testing', $lock));
211
-				} elseif ($type === ILockingProvider::LOCK_SHARED && (int)$this->config->getAppValue('testing', $lock) === ILockingProvider::LOCK_SHARED) {
212
-					$lockingProvider->releaseLock($path, (int)$this->config->getAppValue('testing', $lock));
209
+				if ($type === ILockingProvider::LOCK_EXCLUSIVE && (int) $this->config->getAppValue('testing', $lock) === ILockingProvider::LOCK_EXCLUSIVE) {
210
+					$lockingProvider->releaseLock($path, (int) $this->config->getAppValue('testing', $lock));
211
+				} elseif ($type === ILockingProvider::LOCK_SHARED && (int) $this->config->getAppValue('testing', $lock) === ILockingProvider::LOCK_SHARED) {
212
+					$lockingProvider->releaseLock($path, (int) $this->config->getAppValue('testing', $lock));
213 213
 				} else {
214
-					$lockingProvider->releaseLock($path, (int)$this->config->getAppValue('testing', $lock));
214
+					$lockingProvider->releaseLock($path, (int) $this->config->getAppValue('testing', $lock));
215 215
 				}
216 216
 			}
217 217
 		}
Please login to merge, or discard this patch.
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -23,164 +23,164 @@
 block discarded – undo
23 23
 
24 24
 class LockingController extends OCSController {
25 25
 
26
-	/**
27
-	 * @param string $appName
28
-	 * @param IRequest $request
29
-	 * @param ILockingProvider $lockingProvider
30
-	 * @param FakeDBLockingProvider $fakeDBLockingProvider
31
-	 * @param IDBConnection $connection
32
-	 * @param IConfig $config
33
-	 * @param IRootFolder $rootFolder
34
-	 */
35
-	public function __construct(
36
-		$appName,
37
-		IRequest $request,
38
-		protected ILockingProvider $lockingProvider,
39
-		protected FakeDBLockingProvider $fakeDBLockingProvider,
40
-		protected IDBConnection $connection,
41
-		protected IConfig $config,
42
-		protected IRootFolder $rootFolder,
43
-	) {
44
-		parent::__construct($appName, $request);
45
-	}
46
-
47
-	/**
48
-	 * @throws \RuntimeException
49
-	 */
50
-	protected function getLockingProvider(): ILockingProvider {
51
-		if ($this->lockingProvider instanceof DBLockingProvider) {
52
-			return $this->fakeDBLockingProvider;
53
-		}
54
-		throw new \RuntimeException('Lock provisioning is only possible using the DBLockingProvider');
55
-	}
56
-
57
-	/**
58
-	 * @throws NotFoundException
59
-	 */
60
-	protected function getPath(string $user, string $path): string {
61
-		$node = $this->rootFolder->getUserFolder($user)->get($path);
62
-		return 'files/' . md5($node->getStorage()->getId() . '::' . trim($node->getInternalPath(), '/'));
63
-	}
64
-
65
-	/**
66
-	 * @throws OCSException
67
-	 */
68
-	public function isLockingEnabled(): DataResponse {
69
-		try {
70
-			$this->getLockingProvider();
71
-			return new DataResponse();
72
-		} catch (\RuntimeException $e) {
73
-			throw new OCSException($e->getMessage(), Http::STATUS_NOT_IMPLEMENTED, $e);
74
-		}
75
-	}
76
-
77
-	/**
78
-	 * @throws OCSException
79
-	 */
80
-	public function acquireLock(int $type, string $user, string $path): DataResponse {
81
-		try {
82
-			$path = $this->getPath($user, $path);
83
-		} catch (NoUserException $e) {
84
-			throw new OCSException('User not found', Http::STATUS_NOT_FOUND, $e);
85
-		} catch (NotFoundException $e) {
86
-			throw new OCSException('Path not found', Http::STATUS_NOT_FOUND, $e);
87
-		}
88
-
89
-		$lockingProvider = $this->getLockingProvider();
90
-
91
-		try {
92
-			$lockingProvider->acquireLock($path, $type);
93
-			$this->config->setAppValue('testing', 'locking_' . $path, (string)$type);
94
-			return new DataResponse();
95
-		} catch (LockedException $e) {
96
-			throw new OCSException('', Http::STATUS_LOCKED, $e);
97
-		}
98
-	}
99
-
100
-	/**
101
-	 * @throws OCSException
102
-	 */
103
-	public function changeLock(int $type, string $user, string $path): DataResponse {
104
-		try {
105
-			$path = $this->getPath($user, $path);
106
-		} catch (NoUserException $e) {
107
-			throw new OCSException('User not found', Http::STATUS_NOT_FOUND, $e);
108
-		} catch (NotFoundException $e) {
109
-			throw new OCSException('Path not found', Http::STATUS_NOT_FOUND, $e);
110
-		}
111
-
112
-		$lockingProvider = $this->getLockingProvider();
113
-
114
-		try {
115
-			$lockingProvider->changeLock($path, $type);
116
-			$this->config->setAppValue('testing', 'locking_' . $path, (string)$type);
117
-			return new DataResponse();
118
-		} catch (LockedException $e) {
119
-			throw new OCSException('', Http::STATUS_LOCKED, $e);
120
-		}
121
-	}
122
-
123
-	/**
124
-	 * @throws OCSException
125
-	 */
126
-	public function releaseLock(int $type, string $user, string $path): DataResponse {
127
-		try {
128
-			$path = $this->getPath($user, $path);
129
-		} catch (NoUserException $e) {
130
-			throw new OCSException('User not found', Http::STATUS_NOT_FOUND, $e);
131
-		} catch (NotFoundException $e) {
132
-			throw new OCSException('Path not found', Http::STATUS_NOT_FOUND, $e);
133
-		}
134
-
135
-		$lockingProvider = $this->getLockingProvider();
136
-
137
-		try {
138
-			$lockingProvider->releaseLock($path, $type);
139
-			$this->config->deleteAppValue('testing', 'locking_' . $path);
140
-			return new DataResponse();
141
-		} catch (LockedException $e) {
142
-			throw new OCSException('', Http::STATUS_LOCKED, $e);
143
-		}
144
-	}
145
-
146
-	/**
147
-	 * @throws OCSException
148
-	 */
149
-	public function isLocked(int $type, string $user, string $path): DataResponse {
150
-		try {
151
-			$path = $this->getPath($user, $path);
152
-		} catch (NoUserException $e) {
153
-			throw new OCSException('User not found', Http::STATUS_NOT_FOUND, $e);
154
-		} catch (NotFoundException $e) {
155
-			throw new OCSException('Path not found', Http::STATUS_NOT_FOUND, $e);
156
-		}
157
-
158
-		$lockingProvider = $this->getLockingProvider();
159
-
160
-		if ($lockingProvider->isLocked($path, $type)) {
161
-			return new DataResponse();
162
-		}
163
-
164
-		throw new OCSException('', Http::STATUS_LOCKED);
165
-	}
166
-
167
-	public function releaseAll(?int $type = null): DataResponse {
168
-		$lockingProvider = $this->getLockingProvider();
169
-
170
-		foreach ($this->config->getAppKeys('testing') as $lock) {
171
-			if (strpos($lock, 'locking_') === 0) {
172
-				$path = substr($lock, strlen('locking_'));
173
-
174
-				if ($type === ILockingProvider::LOCK_EXCLUSIVE && (int)$this->config->getAppValue('testing', $lock) === ILockingProvider::LOCK_EXCLUSIVE) {
175
-					$lockingProvider->releaseLock($path, (int)$this->config->getAppValue('testing', $lock));
176
-				} elseif ($type === ILockingProvider::LOCK_SHARED && (int)$this->config->getAppValue('testing', $lock) === ILockingProvider::LOCK_SHARED) {
177
-					$lockingProvider->releaseLock($path, (int)$this->config->getAppValue('testing', $lock));
178
-				} else {
179
-					$lockingProvider->releaseLock($path, (int)$this->config->getAppValue('testing', $lock));
180
-				}
181
-			}
182
-		}
183
-
184
-		return new DataResponse();
185
-	}
26
+    /**
27
+     * @param string $appName
28
+     * @param IRequest $request
29
+     * @param ILockingProvider $lockingProvider
30
+     * @param FakeDBLockingProvider $fakeDBLockingProvider
31
+     * @param IDBConnection $connection
32
+     * @param IConfig $config
33
+     * @param IRootFolder $rootFolder
34
+     */
35
+    public function __construct(
36
+        $appName,
37
+        IRequest $request,
38
+        protected ILockingProvider $lockingProvider,
39
+        protected FakeDBLockingProvider $fakeDBLockingProvider,
40
+        protected IDBConnection $connection,
41
+        protected IConfig $config,
42
+        protected IRootFolder $rootFolder,
43
+    ) {
44
+        parent::__construct($appName, $request);
45
+    }
46
+
47
+    /**
48
+     * @throws \RuntimeException
49
+     */
50
+    protected function getLockingProvider(): ILockingProvider {
51
+        if ($this->lockingProvider instanceof DBLockingProvider) {
52
+            return $this->fakeDBLockingProvider;
53
+        }
54
+        throw new \RuntimeException('Lock provisioning is only possible using the DBLockingProvider');
55
+    }
56
+
57
+    /**
58
+     * @throws NotFoundException
59
+     */
60
+    protected function getPath(string $user, string $path): string {
61
+        $node = $this->rootFolder->getUserFolder($user)->get($path);
62
+        return 'files/' . md5($node->getStorage()->getId() . '::' . trim($node->getInternalPath(), '/'));
63
+    }
64
+
65
+    /**
66
+     * @throws OCSException
67
+     */
68
+    public function isLockingEnabled(): DataResponse {
69
+        try {
70
+            $this->getLockingProvider();
71
+            return new DataResponse();
72
+        } catch (\RuntimeException $e) {
73
+            throw new OCSException($e->getMessage(), Http::STATUS_NOT_IMPLEMENTED, $e);
74
+        }
75
+    }
76
+
77
+    /**
78
+     * @throws OCSException
79
+     */
80
+    public function acquireLock(int $type, string $user, string $path): DataResponse {
81
+        try {
82
+            $path = $this->getPath($user, $path);
83
+        } catch (NoUserException $e) {
84
+            throw new OCSException('User not found', Http::STATUS_NOT_FOUND, $e);
85
+        } catch (NotFoundException $e) {
86
+            throw new OCSException('Path not found', Http::STATUS_NOT_FOUND, $e);
87
+        }
88
+
89
+        $lockingProvider = $this->getLockingProvider();
90
+
91
+        try {
92
+            $lockingProvider->acquireLock($path, $type);
93
+            $this->config->setAppValue('testing', 'locking_' . $path, (string)$type);
94
+            return new DataResponse();
95
+        } catch (LockedException $e) {
96
+            throw new OCSException('', Http::STATUS_LOCKED, $e);
97
+        }
98
+    }
99
+
100
+    /**
101
+     * @throws OCSException
102
+     */
103
+    public function changeLock(int $type, string $user, string $path): DataResponse {
104
+        try {
105
+            $path = $this->getPath($user, $path);
106
+        } catch (NoUserException $e) {
107
+            throw new OCSException('User not found', Http::STATUS_NOT_FOUND, $e);
108
+        } catch (NotFoundException $e) {
109
+            throw new OCSException('Path not found', Http::STATUS_NOT_FOUND, $e);
110
+        }
111
+
112
+        $lockingProvider = $this->getLockingProvider();
113
+
114
+        try {
115
+            $lockingProvider->changeLock($path, $type);
116
+            $this->config->setAppValue('testing', 'locking_' . $path, (string)$type);
117
+            return new DataResponse();
118
+        } catch (LockedException $e) {
119
+            throw new OCSException('', Http::STATUS_LOCKED, $e);
120
+        }
121
+    }
122
+
123
+    /**
124
+     * @throws OCSException
125
+     */
126
+    public function releaseLock(int $type, string $user, string $path): DataResponse {
127
+        try {
128
+            $path = $this->getPath($user, $path);
129
+        } catch (NoUserException $e) {
130
+            throw new OCSException('User not found', Http::STATUS_NOT_FOUND, $e);
131
+        } catch (NotFoundException $e) {
132
+            throw new OCSException('Path not found', Http::STATUS_NOT_FOUND, $e);
133
+        }
134
+
135
+        $lockingProvider = $this->getLockingProvider();
136
+
137
+        try {
138
+            $lockingProvider->releaseLock($path, $type);
139
+            $this->config->deleteAppValue('testing', 'locking_' . $path);
140
+            return new DataResponse();
141
+        } catch (LockedException $e) {
142
+            throw new OCSException('', Http::STATUS_LOCKED, $e);
143
+        }
144
+    }
145
+
146
+    /**
147
+     * @throws OCSException
148
+     */
149
+    public function isLocked(int $type, string $user, string $path): DataResponse {
150
+        try {
151
+            $path = $this->getPath($user, $path);
152
+        } catch (NoUserException $e) {
153
+            throw new OCSException('User not found', Http::STATUS_NOT_FOUND, $e);
154
+        } catch (NotFoundException $e) {
155
+            throw new OCSException('Path not found', Http::STATUS_NOT_FOUND, $e);
156
+        }
157
+
158
+        $lockingProvider = $this->getLockingProvider();
159
+
160
+        if ($lockingProvider->isLocked($path, $type)) {
161
+            return new DataResponse();
162
+        }
163
+
164
+        throw new OCSException('', Http::STATUS_LOCKED);
165
+    }
166
+
167
+    public function releaseAll(?int $type = null): DataResponse {
168
+        $lockingProvider = $this->getLockingProvider();
169
+
170
+        foreach ($this->config->getAppKeys('testing') as $lock) {
171
+            if (strpos($lock, 'locking_') === 0) {
172
+                $path = substr($lock, strlen('locking_'));
173
+
174
+                if ($type === ILockingProvider::LOCK_EXCLUSIVE && (int)$this->config->getAppValue('testing', $lock) === ILockingProvider::LOCK_EXCLUSIVE) {
175
+                    $lockingProvider->releaseLock($path, (int)$this->config->getAppValue('testing', $lock));
176
+                } elseif ($type === ILockingProvider::LOCK_SHARED && (int)$this->config->getAppValue('testing', $lock) === ILockingProvider::LOCK_SHARED) {
177
+                    $lockingProvider->releaseLock($path, (int)$this->config->getAppValue('testing', $lock));
178
+                } else {
179
+                    $lockingProvider->releaseLock($path, (int)$this->config->getAppValue('testing', $lock));
180
+                }
181
+            }
182
+        }
183
+
184
+        return new DataResponse();
185
+    }
186 186
 }
Please login to merge, or discard this patch.
core/Migrations/Version24000Date20211213081604.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -30,37 +30,37 @@
 block discarded – undo
30 30
 use OCP\Migration\SimpleMigrationStep;
31 31
 
32 32
 class Version24000Date20211213081604 extends SimpleMigrationStep {
33
-	/**
34
-	 * @param IOutput $output
35
-	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
36
-	 * @param array $options
37
-	 * @return null|ISchemaWrapper
38
-	 */
39
-	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
40
-		/** @var ISchemaWrapper $schema */
41
-		$schema = $schemaClosure();
33
+    /**
34
+     * @param IOutput $output
35
+     * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
36
+     * @param array $options
37
+     * @return null|ISchemaWrapper
38
+     */
39
+    public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
40
+        /** @var ISchemaWrapper $schema */
41
+        $schema = $schemaClosure();
42 42
 
43
-		$hasTable = $schema->hasTable('ratelimit_entries');
43
+        $hasTable = $schema->hasTable('ratelimit_entries');
44 44
 
45
-		if (!$hasTable) {
46
-			$table = $schema->createTable('ratelimit_entries');
47
-			$table->addColumn('id', Types::BIGINT, [
48
-				'autoincrement' => true,
49
-				'notnull' => true,
50
-			]);
51
-			$table->addColumn('hash', Types::STRING, [
52
-				'notnull' => true,
53
-				'length' => 128,
54
-			]);
55
-			$table->addColumn('delete_after', Types::DATETIME, [
56
-				'notnull' => true,
57
-			]);
58
-			$table->setPrimaryKey(['id']);
59
-			$table->addIndex(['hash'], 'ratelimit_hash');
60
-			$table->addIndex(['delete_after'], 'ratelimit_delete_after');
61
-			return $schema;
62
-		}
45
+        if (!$hasTable) {
46
+            $table = $schema->createTable('ratelimit_entries');
47
+            $table->addColumn('id', Types::BIGINT, [
48
+                'autoincrement' => true,
49
+                'notnull' => true,
50
+            ]);
51
+            $table->addColumn('hash', Types::STRING, [
52
+                'notnull' => true,
53
+                'length' => 128,
54
+            ]);
55
+            $table->addColumn('delete_after', Types::DATETIME, [
56
+                'notnull' => true,
57
+            ]);
58
+            $table->setPrimaryKey(['id']);
59
+            $table->addIndex(['hash'], 'ratelimit_hash');
60
+            $table->addIndex(['delete_after'], 'ratelimit_delete_after');
61
+            return $schema;
62
+        }
63 63
 
64
-		return null;
65
-	}
64
+        return null;
65
+    }
66 66
 }
Please login to merge, or discard this patch.
core/Migrations/Version24000Date20211213081506.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -29,22 +29,22 @@
 block discarded – undo
29 29
 use OCP\Migration\SimpleMigrationStep;
30 30
 
31 31
 class Version24000Date20211213081506 extends SimpleMigrationStep {
32
-	/**
33
-	 * @param IOutput $output
34
-	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
35
-	 * @param array $options
36
-	 * @return null|ISchemaWrapper
37
-	 */
38
-	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
39
-		/** @var ISchemaWrapper $schema */
40
-		$schema = $schemaClosure();
32
+    /**
33
+     * @param IOutput $output
34
+     * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
35
+     * @param array $options
36
+     * @return null|ISchemaWrapper
37
+     */
38
+    public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
39
+        /** @var ISchemaWrapper $schema */
40
+        $schema = $schemaClosure();
41 41
 
42
-		$hasTable = $schema->hasTable('ratelimit_entries');
43
-		if ($hasTable) {
44
-			$schema->dropTable('ratelimit_entries');
45
-			return $schema;
46
-		}
42
+        $hasTable = $schema->hasTable('ratelimit_entries');
43
+        if ($hasTable) {
44
+            $schema->dropTable('ratelimit_entries');
45
+            return $schema;
46
+        }
47 47
 
48
-		return null;
49
-	}
48
+        return null;
49
+    }
50 50
 }
Please login to merge, or discard this patch.
lib/private/Talk/ConversationOptions.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -28,22 +28,22 @@
 block discarded – undo
28 28
 use OCP\Talk\IConversationOptions;
29 29
 
30 30
 class ConversationOptions implements IConversationOptions {
31
-	private bool $isPublic;
31
+    private bool $isPublic;
32 32
 
33
-	private function __construct(bool $isPublic) {
34
-		$this->isPublic = $isPublic;
35
-	}
33
+    private function __construct(bool $isPublic) {
34
+        $this->isPublic = $isPublic;
35
+    }
36 36
 
37
-	public static function default(): self {
38
-		return new self(false);
39
-	}
37
+    public static function default(): self {
38
+        return new self(false);
39
+    }
40 40
 
41
-	public function setPublic(bool $isPublic = true): IConversationOptions {
42
-		$this->isPublic = $isPublic;
43
-		return $this;
44
-	}
41
+    public function setPublic(bool $isPublic = true): IConversationOptions {
42
+        $this->isPublic = $isPublic;
43
+        return $this;
44
+    }
45 45
 
46
-	public function isPublic(): bool {
47
-		return $this->isPublic;
48
-	}
46
+    public function isPublic(): bool {
47
+        return $this->isPublic;
48
+    }
49 49
 }
Please login to merge, or discard this patch.