Completed
Push — master ( 88ba65...9a0892 )
by Christoph
24:20
created
apps/user_ldap/lib/Migration/Version1120Date20210917155206.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -143,7 +143,7 @@
 block discarded – undo
143 143
 
144 144
 	protected function emitUnassign(string $oldId, bool $pre): void {
145 145
 		if ($this->userManager instanceof PublicEmitter) {
146
-			$this->userManager->emit('\OC\User', $pre ? 'pre' : 'post' . 'UnassignedUserId', [$oldId]);
146
+			$this->userManager->emit('\OC\User', $pre ? 'pre' : 'post'.'UnassignedUserId', [$oldId]);
147 147
 		}
148 148
 	}
149 149
 
Please login to merge, or discard this patch.
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -22,110 +22,110 @@
 block discarded – undo
22 22
 
23 23
 class Version1120Date20210917155206 extends SimpleMigrationStep {
24 24
 
25
-	public function __construct(
26
-		private IDBConnection $dbc,
27
-		private IUserManager $userManager,
28
-		private LoggerInterface $logger,
29
-	) {
30
-	}
31
-
32
-	public function getName() {
33
-		return 'Adjust LDAP user and group id column lengths to match server lengths';
34
-	}
35
-
36
-	/**
37
-	 * @param IOutput $output
38
-	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
39
-	 * @param array $options
40
-	 */
41
-	public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
42
-		// ensure that there is no user or group id longer than 64char in LDAP table
43
-		$this->handleIDs('ldap_group_mapping', false);
44
-		$this->handleIDs('ldap_user_mapping', true);
45
-	}
46
-
47
-	/**
48
-	 * @param IOutput $output
49
-	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
50
-	 * @param array $options
51
-	 * @return null|ISchemaWrapper
52
-	 */
53
-	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
54
-		/** @var ISchemaWrapper $schema */
55
-		$schema = $schemaClosure();
56
-
57
-		$changeSchema = false;
58
-		foreach (['ldap_user_mapping', 'ldap_group_mapping'] as $tableName) {
59
-			$table = $schema->getTable($tableName);
60
-			$column = $table->getColumn('owncloud_name');
61
-			if ($column->getLength() > 64) {
62
-				$column->setLength(64);
63
-				$changeSchema = true;
64
-			}
65
-		}
66
-
67
-		return $changeSchema ? $schema : null;
68
-	}
69
-
70
-	protected function handleIDs(string $table, bool $emitHooks) {
71
-		$select = $this->getSelectQuery($table);
72
-		$update = $this->getUpdateQuery($table);
73
-
74
-		$result = $select->executeQuery();
75
-		while ($row = $result->fetch()) {
76
-			$newId = hash('sha256', $row['owncloud_name'], false);
77
-			if ($emitHooks) {
78
-				$this->emitUnassign($row['owncloud_name'], true);
79
-			}
80
-			$update->setParameter('uuid', $row['directory_uuid']);
81
-			$update->setParameter('newId', $newId);
82
-			try {
83
-				$update->executeStatement();
84
-				if ($emitHooks) {
85
-					$this->emitUnassign($row['owncloud_name'], false);
86
-					$this->emitAssign($newId);
87
-				}
88
-			} catch (Exception $e) {
89
-				$this->logger->error('Failed to shorten owncloud_name "{oldId}" to "{newId}" (UUID: "{uuid}" of {table})',
90
-					[
91
-						'app' => 'user_ldap',
92
-						'oldId' => $row['owncloud_name'],
93
-						'newId' => $newId,
94
-						'uuid' => $row['directory_uuid'],
95
-						'table' => $table,
96
-						'exception' => $e,
97
-					]
98
-				);
99
-			}
100
-		}
101
-		$result->closeCursor();
102
-	}
103
-
104
-	protected function getSelectQuery(string $table): IQueryBuilder {
105
-		$qb = $this->dbc->getQueryBuilder();
106
-		$qb->select('owncloud_name', 'directory_uuid')
107
-			->from($table)
108
-			->where($qb->expr()->gt($qb->func()->octetLength('owncloud_name'), $qb->createNamedParameter('64'), IQueryBuilder::PARAM_INT));
109
-		return $qb;
110
-	}
111
-
112
-	protected function getUpdateQuery(string $table): IQueryBuilder {
113
-		$qb = $this->dbc->getQueryBuilder();
114
-		$qb->update($table)
115
-			->set('owncloud_name', $qb->createParameter('newId'))
116
-			->where($qb->expr()->eq('directory_uuid', $qb->createParameter('uuid')));
117
-		return $qb;
118
-	}
119
-
120
-	protected function emitUnassign(string $oldId, bool $pre): void {
121
-		if ($this->userManager instanceof PublicEmitter) {
122
-			$this->userManager->emit('\OC\User', $pre ? 'pre' : 'post' . 'UnassignedUserId', [$oldId]);
123
-		}
124
-	}
125
-
126
-	protected function emitAssign(string $newId): void {
127
-		if ($this->userManager instanceof PublicEmitter) {
128
-			$this->userManager->emit('\OC\User', 'assignedUserId', [$newId]);
129
-		}
130
-	}
25
+    public function __construct(
26
+        private IDBConnection $dbc,
27
+        private IUserManager $userManager,
28
+        private LoggerInterface $logger,
29
+    ) {
30
+    }
31
+
32
+    public function getName() {
33
+        return 'Adjust LDAP user and group id column lengths to match server lengths';
34
+    }
35
+
36
+    /**
37
+     * @param IOutput $output
38
+     * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
39
+     * @param array $options
40
+     */
41
+    public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
42
+        // ensure that there is no user or group id longer than 64char in LDAP table
43
+        $this->handleIDs('ldap_group_mapping', false);
44
+        $this->handleIDs('ldap_user_mapping', true);
45
+    }
46
+
47
+    /**
48
+     * @param IOutput $output
49
+     * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
50
+     * @param array $options
51
+     * @return null|ISchemaWrapper
52
+     */
53
+    public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
54
+        /** @var ISchemaWrapper $schema */
55
+        $schema = $schemaClosure();
56
+
57
+        $changeSchema = false;
58
+        foreach (['ldap_user_mapping', 'ldap_group_mapping'] as $tableName) {
59
+            $table = $schema->getTable($tableName);
60
+            $column = $table->getColumn('owncloud_name');
61
+            if ($column->getLength() > 64) {
62
+                $column->setLength(64);
63
+                $changeSchema = true;
64
+            }
65
+        }
66
+
67
+        return $changeSchema ? $schema : null;
68
+    }
69
+
70
+    protected function handleIDs(string $table, bool $emitHooks) {
71
+        $select = $this->getSelectQuery($table);
72
+        $update = $this->getUpdateQuery($table);
73
+
74
+        $result = $select->executeQuery();
75
+        while ($row = $result->fetch()) {
76
+            $newId = hash('sha256', $row['owncloud_name'], false);
77
+            if ($emitHooks) {
78
+                $this->emitUnassign($row['owncloud_name'], true);
79
+            }
80
+            $update->setParameter('uuid', $row['directory_uuid']);
81
+            $update->setParameter('newId', $newId);
82
+            try {
83
+                $update->executeStatement();
84
+                if ($emitHooks) {
85
+                    $this->emitUnassign($row['owncloud_name'], false);
86
+                    $this->emitAssign($newId);
87
+                }
88
+            } catch (Exception $e) {
89
+                $this->logger->error('Failed to shorten owncloud_name "{oldId}" to "{newId}" (UUID: "{uuid}" of {table})',
90
+                    [
91
+                        'app' => 'user_ldap',
92
+                        'oldId' => $row['owncloud_name'],
93
+                        'newId' => $newId,
94
+                        'uuid' => $row['directory_uuid'],
95
+                        'table' => $table,
96
+                        'exception' => $e,
97
+                    ]
98
+                );
99
+            }
100
+        }
101
+        $result->closeCursor();
102
+    }
103
+
104
+    protected function getSelectQuery(string $table): IQueryBuilder {
105
+        $qb = $this->dbc->getQueryBuilder();
106
+        $qb->select('owncloud_name', 'directory_uuid')
107
+            ->from($table)
108
+            ->where($qb->expr()->gt($qb->func()->octetLength('owncloud_name'), $qb->createNamedParameter('64'), IQueryBuilder::PARAM_INT));
109
+        return $qb;
110
+    }
111
+
112
+    protected function getUpdateQuery(string $table): IQueryBuilder {
113
+        $qb = $this->dbc->getQueryBuilder();
114
+        $qb->update($table)
115
+            ->set('owncloud_name', $qb->createParameter('newId'))
116
+            ->where($qb->expr()->eq('directory_uuid', $qb->createParameter('uuid')));
117
+        return $qb;
118
+    }
119
+
120
+    protected function emitUnassign(string $oldId, bool $pre): void {
121
+        if ($this->userManager instanceof PublicEmitter) {
122
+            $this->userManager->emit('\OC\User', $pre ? 'pre' : 'post' . 'UnassignedUserId', [$oldId]);
123
+        }
124
+    }
125
+
126
+    protected function emitAssign(string $newId): void {
127
+        if ($this->userManager instanceof PublicEmitter) {
128
+            $this->userManager->emit('\OC\User', 'assignedUserId', [$newId]);
129
+        }
130
+    }
131 131
 }
Please login to merge, or discard this patch.
lib/private/Files/ObjectStore/SwiftFactory.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	}
92 92
 
93 93
 	private function getCachedToken(string $cacheKey) {
94
-		$cachedTokenString = $this->cache->get($cacheKey . '/token');
94
+		$cachedTokenString = $this->cache->get($cacheKey.'/token');
95 95
 		if ($cachedTokenString) {
96 96
 			return json_decode($cachedTokenString, true);
97 97
 		} else {
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 		}
118 118
 
119 119
 		$this->params['cachedToken'] = $value;
120
-		$this->cache->set($cacheKey . '/token', json_encode($value));
120
+		$this->cache->set($cacheKey.'/token', json_encode($value));
121 121
 	}
122 122
 
123 123
 	/**
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 		}
149 149
 		$this->params = array_merge(self::DEFAULT_OPTIONS, $this->params);
150 150
 
151
-		$cacheKey = $userName . '@' . $this->params['url'] . '/' . $this->params['container'];
151
+		$cacheKey = $userName.'@'.$this->params['url'].'/'.$this->params['container'];
152 152
 		$token = $this->getCachedToken($cacheKey);
153 153
 		$this->params['cachedToken'] = $token;
154 154
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 			if ($authService instanceof IdentityV3Service) {
185 185
 				$token = $authService->generateTokenFromCache($cachedToken);
186 186
 				if (\is_null($token->catalog)) {
187
-					$this->logger->warning('Invalid cached token for swift, no catalog set: ' . json_encode($cachedToken));
187
+					$this->logger->warning('Invalid cached token for swift, no catalog set: '.json_encode($cachedToken));
188 188
 				} elseif ($token->hasExpired()) {
189 189
 					$this->logger->debug('Cached token for swift expired');
190 190
 				} else {
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 		} catch (ConnectException $e) {
279 279
 			/** @var RequestInterface $request */
280 280
 			$request = $e->getRequest();
281
-			$host = $request->getUri()->getHost() . ':' . $request->getUri()->getPort();
281
+			$host = $request->getUri()->getHost().':'.$request->getUri()->getPort();
282 282
 			$this->logger->error("Can't connect to object storage server at $host", ['exception' => $e]);
283 283
 			throw new StorageNotAvailableException("Can't connect to object storage server at $host", StorageNotAvailableException::STATUS_ERROR, $e);
284 284
 		}
Please login to merge, or discard this patch.
Indentation   +208 added lines, -208 removed lines patch added patch discarded remove patch
@@ -28,235 +28,235 @@
 block discarded – undo
28 28
 use Psr\Log\LoggerInterface;
29 29
 
30 30
 class SwiftFactory {
31
-	private $cache;
32
-	private $params;
33
-	/** @var Container|null */
34
-	private $container = null;
35
-	private LoggerInterface $logger;
31
+    private $cache;
32
+    private $params;
33
+    /** @var Container|null */
34
+    private $container = null;
35
+    private LoggerInterface $logger;
36 36
 
37
-	public const DEFAULT_OPTIONS = [
38
-		'autocreate' => false,
39
-		'urlType' => 'publicURL',
40
-		'catalogName' => 'swift',
41
-		'catalogType' => 'object-store'
42
-	];
37
+    public const DEFAULT_OPTIONS = [
38
+        'autocreate' => false,
39
+        'urlType' => 'publicURL',
40
+        'catalogName' => 'swift',
41
+        'catalogType' => 'object-store'
42
+    ];
43 43
 
44
-	public function __construct(ICache $cache, array $params, LoggerInterface $logger) {
45
-		$this->cache = $cache;
46
-		$this->params = $params;
47
-		$this->logger = $logger;
48
-	}
44
+    public function __construct(ICache $cache, array $params, LoggerInterface $logger) {
45
+        $this->cache = $cache;
46
+        $this->params = $params;
47
+        $this->logger = $logger;
48
+    }
49 49
 
50
-	/**
51
-	 * Gets currently cached token id
52
-	 *
53
-	 * @return string
54
-	 * @throws StorageAuthException
55
-	 */
56
-	public function getCachedTokenId() {
57
-		if (!isset($this->params['cachedToken'])) {
58
-			throw new StorageAuthException('Unauthenticated ObjectStore connection');
59
-		}
50
+    /**
51
+     * Gets currently cached token id
52
+     *
53
+     * @return string
54
+     * @throws StorageAuthException
55
+     */
56
+    public function getCachedTokenId() {
57
+        if (!isset($this->params['cachedToken'])) {
58
+            throw new StorageAuthException('Unauthenticated ObjectStore connection');
59
+        }
60 60
 
61
-		// Is it V2 token?
62
-		if (isset($this->params['cachedToken']['token'])) {
63
-			return $this->params['cachedToken']['token']['id'];
64
-		}
61
+        // Is it V2 token?
62
+        if (isset($this->params['cachedToken']['token'])) {
63
+            return $this->params['cachedToken']['token']['id'];
64
+        }
65 65
 
66
-		return $this->params['cachedToken']['id'];
67
-	}
66
+        return $this->params['cachedToken']['id'];
67
+    }
68 68
 
69
-	private function getCachedToken(string $cacheKey) {
70
-		$cachedTokenString = $this->cache->get($cacheKey . '/token');
71
-		if ($cachedTokenString) {
72
-			return json_decode($cachedTokenString, true);
73
-		} else {
74
-			return null;
75
-		}
76
-	}
69
+    private function getCachedToken(string $cacheKey) {
70
+        $cachedTokenString = $this->cache->get($cacheKey . '/token');
71
+        if ($cachedTokenString) {
72
+            return json_decode($cachedTokenString, true);
73
+        } else {
74
+            return null;
75
+        }
76
+    }
77 77
 
78
-	private function cacheToken(Token $token, string $serviceUrl, string $cacheKey) {
79
-		if ($token instanceof \OpenStack\Identity\v3\Models\Token) {
80
-			// for v3 the catalog is cached as part of the token, so no need to cache $serviceUrl separately
81
-			$value = $token->export();
82
-		} else {
83
-			/** @var \OpenStack\Identity\v2\Models\Token $token */
84
-			$value = [
85
-				'serviceUrl' => $serviceUrl,
86
-				'token' => [
87
-					'issued_at' => $token->issuedAt->format('c'),
88
-					'expires' => $token->expires->format('c'),
89
-					'id' => $token->id,
90
-					'tenant' => $token->tenant
91
-				]
92
-			];
93
-		}
78
+    private function cacheToken(Token $token, string $serviceUrl, string $cacheKey) {
79
+        if ($token instanceof \OpenStack\Identity\v3\Models\Token) {
80
+            // for v3 the catalog is cached as part of the token, so no need to cache $serviceUrl separately
81
+            $value = $token->export();
82
+        } else {
83
+            /** @var \OpenStack\Identity\v2\Models\Token $token */
84
+            $value = [
85
+                'serviceUrl' => $serviceUrl,
86
+                'token' => [
87
+                    'issued_at' => $token->issuedAt->format('c'),
88
+                    'expires' => $token->expires->format('c'),
89
+                    'id' => $token->id,
90
+                    'tenant' => $token->tenant
91
+                ]
92
+            ];
93
+        }
94 94
 
95
-		$this->params['cachedToken'] = $value;
96
-		$this->cache->set($cacheKey . '/token', json_encode($value));
97
-	}
95
+        $this->params['cachedToken'] = $value;
96
+        $this->cache->set($cacheKey . '/token', json_encode($value));
97
+    }
98 98
 
99
-	/**
100
-	 * @return OpenStack
101
-	 * @throws StorageAuthException
102
-	 */
103
-	private function getClient() {
104
-		if (isset($this->params['bucket'])) {
105
-			$this->params['container'] = $this->params['bucket'];
106
-		}
107
-		if (!isset($this->params['container'])) {
108
-			$this->params['container'] = 'nextcloud';
109
-		}
110
-		if (isset($this->params['user']) && is_array($this->params['user'])) {
111
-			$userName = $this->params['user']['name'];
112
-		} else {
113
-			if (!isset($this->params['username']) && isset($this->params['user'])) {
114
-				$this->params['username'] = $this->params['user'];
115
-			}
116
-			$userName = $this->params['username'];
117
-		}
118
-		if (!isset($this->params['tenantName']) && isset($this->params['tenant'])) {
119
-			$this->params['tenantName'] = $this->params['tenant'];
120
-		}
121
-		if (isset($this->params['domain'])) {
122
-			$this->params['scope']['project']['name'] = $this->params['tenant'];
123
-			$this->params['scope']['project']['domain']['name'] = $this->params['domain'];
124
-		}
125
-		$this->params = array_merge(self::DEFAULT_OPTIONS, $this->params);
99
+    /**
100
+     * @return OpenStack
101
+     * @throws StorageAuthException
102
+     */
103
+    private function getClient() {
104
+        if (isset($this->params['bucket'])) {
105
+            $this->params['container'] = $this->params['bucket'];
106
+        }
107
+        if (!isset($this->params['container'])) {
108
+            $this->params['container'] = 'nextcloud';
109
+        }
110
+        if (isset($this->params['user']) && is_array($this->params['user'])) {
111
+            $userName = $this->params['user']['name'];
112
+        } else {
113
+            if (!isset($this->params['username']) && isset($this->params['user'])) {
114
+                $this->params['username'] = $this->params['user'];
115
+            }
116
+            $userName = $this->params['username'];
117
+        }
118
+        if (!isset($this->params['tenantName']) && isset($this->params['tenant'])) {
119
+            $this->params['tenantName'] = $this->params['tenant'];
120
+        }
121
+        if (isset($this->params['domain'])) {
122
+            $this->params['scope']['project']['name'] = $this->params['tenant'];
123
+            $this->params['scope']['project']['domain']['name'] = $this->params['domain'];
124
+        }
125
+        $this->params = array_merge(self::DEFAULT_OPTIONS, $this->params);
126 126
 
127
-		$cacheKey = $userName . '@' . $this->params['url'] . '/' . $this->params['container'];
128
-		$token = $this->getCachedToken($cacheKey);
129
-		$this->params['cachedToken'] = $token;
127
+        $cacheKey = $userName . '@' . $this->params['url'] . '/' . $this->params['container'];
128
+        $token = $this->getCachedToken($cacheKey);
129
+        $this->params['cachedToken'] = $token;
130 130
 
131
-		$httpClient = new Client([
132
-			'base_uri' => TransportUtils::normalizeUrl($this->params['url']),
133
-			'handler' => HandlerStack::create()
134
-		]);
131
+        $httpClient = new Client([
132
+            'base_uri' => TransportUtils::normalizeUrl($this->params['url']),
133
+            'handler' => HandlerStack::create()
134
+        ]);
135 135
 
136
-		if (isset($this->params['user']) && is_array($this->params['user']) && isset($this->params['user']['name'])) {
137
-			if (!isset($this->params['scope'])) {
138
-				throw new StorageAuthException('Scope has to be defined for V3 requests');
139
-			}
136
+        if (isset($this->params['user']) && is_array($this->params['user']) && isset($this->params['user']['name'])) {
137
+            if (!isset($this->params['scope'])) {
138
+                throw new StorageAuthException('Scope has to be defined for V3 requests');
139
+            }
140 140
 
141
-			return $this->auth(IdentityV3Service::factory($httpClient), $cacheKey);
142
-		} else {
143
-			return $this->auth(SwiftV2CachingAuthService::factory($httpClient), $cacheKey);
144
-		}
145
-	}
141
+            return $this->auth(IdentityV3Service::factory($httpClient), $cacheKey);
142
+        } else {
143
+            return $this->auth(SwiftV2CachingAuthService::factory($httpClient), $cacheKey);
144
+        }
145
+    }
146 146
 
147
-	/**
148
-	 * @param IdentityV2Service|IdentityV3Service $authService
149
-	 * @param string $cacheKey
150
-	 * @return OpenStack
151
-	 * @throws StorageAuthException
152
-	 */
153
-	private function auth($authService, string $cacheKey) {
154
-		$this->params['identityService'] = $authService;
155
-		$this->params['authUrl'] = $this->params['url'];
147
+    /**
148
+     * @param IdentityV2Service|IdentityV3Service $authService
149
+     * @param string $cacheKey
150
+     * @return OpenStack
151
+     * @throws StorageAuthException
152
+     */
153
+    private function auth($authService, string $cacheKey) {
154
+        $this->params['identityService'] = $authService;
155
+        $this->params['authUrl'] = $this->params['url'];
156 156
 
157
-		$cachedToken = $this->params['cachedToken'];
158
-		$hasValidCachedToken = false;
159
-		if (\is_array($cachedToken)) {
160
-			if ($authService instanceof IdentityV3Service) {
161
-				$token = $authService->generateTokenFromCache($cachedToken);
162
-				if (\is_null($token->catalog)) {
163
-					$this->logger->warning('Invalid cached token for swift, no catalog set: ' . json_encode($cachedToken));
164
-				} elseif ($token->hasExpired()) {
165
-					$this->logger->debug('Cached token for swift expired');
166
-				} else {
167
-					$hasValidCachedToken = true;
168
-				}
169
-			} else {
170
-				try {
171
-					/** @var \OpenStack\Identity\v2\Models\Token $token */
172
-					$token = $authService->model(\OpenStack\Identity\v2\Models\Token::class, $cachedToken['token']);
173
-					$now = new \DateTimeImmutable('now');
174
-					if ($token->expires > $now) {
175
-						$hasValidCachedToken = true;
176
-						$this->params['v2cachedToken'] = $token;
177
-						$this->params['v2serviceUrl'] = $cachedToken['serviceUrl'];
178
-					} else {
179
-						$this->logger->debug('Cached token for swift expired');
180
-					}
181
-				} catch (\Exception $e) {
182
-					$this->logger->error($e->getMessage(), ['exception' => $e]);
183
-				}
184
-			}
185
-		}
157
+        $cachedToken = $this->params['cachedToken'];
158
+        $hasValidCachedToken = false;
159
+        if (\is_array($cachedToken)) {
160
+            if ($authService instanceof IdentityV3Service) {
161
+                $token = $authService->generateTokenFromCache($cachedToken);
162
+                if (\is_null($token->catalog)) {
163
+                    $this->logger->warning('Invalid cached token for swift, no catalog set: ' . json_encode($cachedToken));
164
+                } elseif ($token->hasExpired()) {
165
+                    $this->logger->debug('Cached token for swift expired');
166
+                } else {
167
+                    $hasValidCachedToken = true;
168
+                }
169
+            } else {
170
+                try {
171
+                    /** @var \OpenStack\Identity\v2\Models\Token $token */
172
+                    $token = $authService->model(\OpenStack\Identity\v2\Models\Token::class, $cachedToken['token']);
173
+                    $now = new \DateTimeImmutable('now');
174
+                    if ($token->expires > $now) {
175
+                        $hasValidCachedToken = true;
176
+                        $this->params['v2cachedToken'] = $token;
177
+                        $this->params['v2serviceUrl'] = $cachedToken['serviceUrl'];
178
+                    } else {
179
+                        $this->logger->debug('Cached token for swift expired');
180
+                    }
181
+                } catch (\Exception $e) {
182
+                    $this->logger->error($e->getMessage(), ['exception' => $e]);
183
+                }
184
+            }
185
+        }
186 186
 
187
-		if (!$hasValidCachedToken) {
188
-			unset($this->params['cachedToken']);
189
-			try {
190
-				[$token, $serviceUrl] = $authService->authenticate($this->params);
191
-				$this->cacheToken($token, $serviceUrl, $cacheKey);
192
-			} catch (ConnectException $e) {
193
-				throw new StorageAuthException('Failed to connect to keystone, verify the keystone url', $e);
194
-			} catch (ClientException $e) {
195
-				$statusCode = $e->getResponse()->getStatusCode();
196
-				if ($statusCode === 404) {
197
-					throw new StorageAuthException('Keystone not found while connecting to object storage, verify the keystone url', $e);
198
-				} elseif ($statusCode === 412) {
199
-					throw new StorageAuthException('Precondition failed while connecting to object storage, verify the keystone url', $e);
200
-				} elseif ($statusCode === 401) {
201
-					throw new StorageAuthException('Authentication failed while connecting to object storage, verify the username, password and possibly tenant', $e);
202
-				} else {
203
-					throw new StorageAuthException('Unknown error while connecting to object storage', $e);
204
-				}
205
-			} catch (RequestException $e) {
206
-				throw new StorageAuthException('Connection reset while connecting to keystone, verify the keystone url', $e);
207
-			}
208
-		}
187
+        if (!$hasValidCachedToken) {
188
+            unset($this->params['cachedToken']);
189
+            try {
190
+                [$token, $serviceUrl] = $authService->authenticate($this->params);
191
+                $this->cacheToken($token, $serviceUrl, $cacheKey);
192
+            } catch (ConnectException $e) {
193
+                throw new StorageAuthException('Failed to connect to keystone, verify the keystone url', $e);
194
+            } catch (ClientException $e) {
195
+                $statusCode = $e->getResponse()->getStatusCode();
196
+                if ($statusCode === 404) {
197
+                    throw new StorageAuthException('Keystone not found while connecting to object storage, verify the keystone url', $e);
198
+                } elseif ($statusCode === 412) {
199
+                    throw new StorageAuthException('Precondition failed while connecting to object storage, verify the keystone url', $e);
200
+                } elseif ($statusCode === 401) {
201
+                    throw new StorageAuthException('Authentication failed while connecting to object storage, verify the username, password and possibly tenant', $e);
202
+                } else {
203
+                    throw new StorageAuthException('Unknown error while connecting to object storage', $e);
204
+                }
205
+            } catch (RequestException $e) {
206
+                throw new StorageAuthException('Connection reset while connecting to keystone, verify the keystone url', $e);
207
+            }
208
+        }
209 209
 
210 210
 
211
-		$client = new OpenStack($this->params);
211
+        $client = new OpenStack($this->params);
212 212
 
213
-		return $client;
214
-	}
213
+        return $client;
214
+    }
215 215
 
216
-	/**
217
-	 * @return \OpenStack\ObjectStore\v1\Models\Container
218
-	 * @throws StorageAuthException
219
-	 * @throws StorageNotAvailableException
220
-	 */
221
-	public function getContainer() {
222
-		if (is_null($this->container)) {
223
-			$this->container = $this->createContainer();
224
-		}
216
+    /**
217
+     * @return \OpenStack\ObjectStore\v1\Models\Container
218
+     * @throws StorageAuthException
219
+     * @throws StorageNotAvailableException
220
+     */
221
+    public function getContainer() {
222
+        if (is_null($this->container)) {
223
+            $this->container = $this->createContainer();
224
+        }
225 225
 
226
-		return $this->container;
227
-	}
226
+        return $this->container;
227
+    }
228 228
 
229
-	/**
230
-	 * @return \OpenStack\ObjectStore\v1\Models\Container
231
-	 * @throws StorageAuthException
232
-	 * @throws StorageNotAvailableException
233
-	 */
234
-	private function createContainer() {
235
-		$client = $this->getClient();
236
-		$objectStoreService = $client->objectStoreV1();
229
+    /**
230
+     * @return \OpenStack\ObjectStore\v1\Models\Container
231
+     * @throws StorageAuthException
232
+     * @throws StorageNotAvailableException
233
+     */
234
+    private function createContainer() {
235
+        $client = $this->getClient();
236
+        $objectStoreService = $client->objectStoreV1();
237 237
 
238
-		$autoCreate = isset($this->params['autocreate']) && $this->params['autocreate'] === true;
239
-		try {
240
-			$container = $objectStoreService->getContainer($this->params['container']);
241
-			if ($autoCreate) {
242
-				$container->getMetadata();
243
-			}
244
-			return $container;
245
-		} catch (BadResponseError $ex) {
246
-			// if the container does not exist and autocreate is true try to create the container on the fly
247
-			if ($ex->getResponse()->getStatusCode() === 404 && $autoCreate) {
248
-				return $objectStoreService->createContainer([
249
-					'name' => $this->params['container']
250
-				]);
251
-			} else {
252
-				throw new StorageNotAvailableException('Invalid response while trying to get container info', StorageNotAvailableException::STATUS_ERROR, $ex);
253
-			}
254
-		} catch (ConnectException $e) {
255
-			/** @var RequestInterface $request */
256
-			$request = $e->getRequest();
257
-			$host = $request->getUri()->getHost() . ':' . $request->getUri()->getPort();
258
-			$this->logger->error("Can't connect to object storage server at $host", ['exception' => $e]);
259
-			throw new StorageNotAvailableException("Can't connect to object storage server at $host", StorageNotAvailableException::STATUS_ERROR, $e);
260
-		}
261
-	}
238
+        $autoCreate = isset($this->params['autocreate']) && $this->params['autocreate'] === true;
239
+        try {
240
+            $container = $objectStoreService->getContainer($this->params['container']);
241
+            if ($autoCreate) {
242
+                $container->getMetadata();
243
+            }
244
+            return $container;
245
+        } catch (BadResponseError $ex) {
246
+            // if the container does not exist and autocreate is true try to create the container on the fly
247
+            if ($ex->getResponse()->getStatusCode() === 404 && $autoCreate) {
248
+                return $objectStoreService->createContainer([
249
+                    'name' => $this->params['container']
250
+                ]);
251
+            } else {
252
+                throw new StorageNotAvailableException('Invalid response while trying to get container info', StorageNotAvailableException::STATUS_ERROR, $ex);
253
+            }
254
+        } catch (ConnectException $e) {
255
+            /** @var RequestInterface $request */
256
+            $request = $e->getRequest();
257
+            $host = $request->getUri()->getHost() . ':' . $request->getUri()->getPort();
258
+            $this->logger->error("Can't connect to object storage server at $host", ['exception' => $e]);
259
+            throw new StorageNotAvailableException("Can't connect to object storage server at $host", StorageNotAvailableException::STATUS_ERROR, $e);
260
+        }
261
+    }
262 262
 }
Please login to merge, or discard this patch.
lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 			return;
75 75
 		}
76 76
 
77
-		$folders = array_filter($folders, function (ISimpleFolder $folder) {
77
+		$folders = array_filter($folders, function(ISimpleFolder $folder) {
78 78
 			return $folder->fileExists('photo.');
79 79
 		});
80 80
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 			return;
83 83
 		}
84 84
 
85
-		$output->info('Delete ' . count($folders) . ' "photo." files');
85
+		$output->info('Delete '.count($folders).' "photo." files');
86 86
 
87 87
 		foreach ($folders as $folder) {
88 88
 			try {
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 				$folder->getFile('photo.')->delete();
91 91
 			} catch (\Exception $e) {
92 92
 				$this->logger->error($e->getMessage(), ['exception' => $e]);
93
-				$output->warning('Could not delete file "dav-photocache/' . $folder->getName() . '/photo."');
93
+				$output->warning('Could not delete file "dav-photocache/'.$folder->getName().'/photo."');
94 94
 			}
95 95
 		}
96 96
 	}
Please login to merge, or discard this patch.
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -28,61 +28,61 @@
 block discarded – undo
28 28
  * photo could be returned for this vcard. These invalid files are removed by this migration step.
29 29
  */
30 30
 class CleanupCardDAVPhotoCache implements IRepairStep {
31
-	public function __construct(
32
-		private IConfig $config,
33
-		private IAppDataFactory $appDataFactory,
34
-		private LoggerInterface $logger,
35
-	) {
36
-	}
31
+    public function __construct(
32
+        private IConfig $config,
33
+        private IAppDataFactory $appDataFactory,
34
+        private LoggerInterface $logger,
35
+    ) {
36
+    }
37 37
 
38
-	public function getName(): string {
39
-		return 'Cleanup invalid photocache files for carddav';
40
-	}
38
+    public function getName(): string {
39
+        return 'Cleanup invalid photocache files for carddav';
40
+    }
41 41
 
42
-	private function repair(IOutput $output): void {
43
-		$photoCacheAppData = $this->appDataFactory->get('dav-photocache');
42
+    private function repair(IOutput $output): void {
43
+        $photoCacheAppData = $this->appDataFactory->get('dav-photocache');
44 44
 
45
-		try {
46
-			$folders = $photoCacheAppData->getDirectoryListing();
47
-		} catch (NotFoundException $e) {
48
-			return;
49
-		} catch (RuntimeException $e) {
50
-			$this->logger->error('Failed to fetch directory listing in CleanupCardDAVPhotoCache', ['exception' => $e]);
51
-			return;
52
-		}
45
+        try {
46
+            $folders = $photoCacheAppData->getDirectoryListing();
47
+        } catch (NotFoundException $e) {
48
+            return;
49
+        } catch (RuntimeException $e) {
50
+            $this->logger->error('Failed to fetch directory listing in CleanupCardDAVPhotoCache', ['exception' => $e]);
51
+            return;
52
+        }
53 53
 
54
-		$folders = array_filter($folders, function (ISimpleFolder $folder) {
55
-			return $folder->fileExists('photo.');
56
-		});
54
+        $folders = array_filter($folders, function (ISimpleFolder $folder) {
55
+            return $folder->fileExists('photo.');
56
+        });
57 57
 
58
-		if (empty($folders)) {
59
-			return;
60
-		}
58
+        if (empty($folders)) {
59
+            return;
60
+        }
61 61
 
62
-		$output->info('Delete ' . count($folders) . ' "photo." files');
62
+        $output->info('Delete ' . count($folders) . ' "photo." files');
63 63
 
64
-		foreach ($folders as $folder) {
65
-			try {
66
-				/** @var ISimpleFolder $folder */
67
-				$folder->getFile('photo.')->delete();
68
-			} catch (\Exception $e) {
69
-				$this->logger->error($e->getMessage(), ['exception' => $e]);
70
-				$output->warning('Could not delete file "dav-photocache/' . $folder->getName() . '/photo."');
71
-			}
72
-		}
73
-	}
64
+        foreach ($folders as $folder) {
65
+            try {
66
+                /** @var ISimpleFolder $folder */
67
+                $folder->getFile('photo.')->delete();
68
+            } catch (\Exception $e) {
69
+                $this->logger->error($e->getMessage(), ['exception' => $e]);
70
+                $output->warning('Could not delete file "dav-photocache/' . $folder->getName() . '/photo."');
71
+            }
72
+        }
73
+    }
74 74
 
75
-	private function shouldRun(): bool {
76
-		return version_compare(
77
-			$this->config->getSystemValueString('version', '0.0.0.0'),
78
-			'16.0.0.0',
79
-			'<='
80
-		);
81
-	}
75
+    private function shouldRun(): bool {
76
+        return version_compare(
77
+            $this->config->getSystemValueString('version', '0.0.0.0'),
78
+            '16.0.0.0',
79
+            '<='
80
+        );
81
+    }
82 82
 
83
-	public function run(IOutput $output): void {
84
-		if ($this->shouldRun()) {
85
-			$this->repair($output);
86
-		}
87
-	}
83
+    public function run(IOutput $output): void {
84
+        if ($this->shouldRun()) {
85
+            $this->repair($output);
86
+        }
87
+    }
88 88
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/Migration/Version1130Date20220110154718.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -32,68 +32,68 @@
 block discarded – undo
32 32
 use OCP\Migration\IOutput;
33 33
 
34 34
 class Version1130Date20220110154718 extends GroupMappingMigration {
35
-	public function getName() {
36
-		return 'Copy ldap_group_mapping data from backup table and if needed';
37
-	}
35
+    public function getName() {
36
+        return 'Copy ldap_group_mapping data from backup table and if needed';
37
+    }
38 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();
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 48
 
49
-		if (!$schema->hasTable('ldap_group_mapping_backup')) {
50
-			// Backup table does not exist
51
-			return null;
52
-		}
49
+        if (!$schema->hasTable('ldap_group_mapping_backup')) {
50
+            // Backup table does not exist
51
+            return null;
52
+        }
53 53
 
54
-		$table = $schema->createTable('ldap_group_mapping');
55
-		$table->addColumn('ldap_dn', Types::STRING, [
56
-			'notnull' => true,
57
-			'length' => 4000,
58
-			'default' => '',
59
-		]);
60
-		$table->addColumn('owncloud_name', Types::STRING, [
61
-			'notnull' => true,
62
-			'length' => 64,
63
-			'default' => '',
64
-		]);
65
-		$table->addColumn('directory_uuid', Types::STRING, [
66
-			'notnull' => true,
67
-			'length' => 255,
68
-			'default' => '',
69
-		]);
70
-		$table->addColumn('ldap_dn_hash', Types::STRING, [
71
-			'notnull' => false,
72
-			'length' => 64,
73
-		]);
74
-		$table->setPrimaryKey(['owncloud_name']);
75
-		$table->addUniqueIndex(['ldap_dn_hash'], 'ldap_group_dn_hashes');
76
-		$table->addUniqueIndex(['directory_uuid'], 'ldap_group_directory_uuid');
54
+        $table = $schema->createTable('ldap_group_mapping');
55
+        $table->addColumn('ldap_dn', Types::STRING, [
56
+            'notnull' => true,
57
+            'length' => 4000,
58
+            'default' => '',
59
+        ]);
60
+        $table->addColumn('owncloud_name', Types::STRING, [
61
+            'notnull' => true,
62
+            'length' => 64,
63
+            'default' => '',
64
+        ]);
65
+        $table->addColumn('directory_uuid', Types::STRING, [
66
+            'notnull' => true,
67
+            'length' => 255,
68
+            'default' => '',
69
+        ]);
70
+        $table->addColumn('ldap_dn_hash', Types::STRING, [
71
+            'notnull' => false,
72
+            'length' => 64,
73
+        ]);
74
+        $table->setPrimaryKey(['owncloud_name']);
75
+        $table->addUniqueIndex(['ldap_dn_hash'], 'ldap_group_dn_hashes');
76
+        $table->addUniqueIndex(['directory_uuid'], 'ldap_group_directory_uuid');
77 77
 
78
-		return $schema;
79
-	}
78
+        return $schema;
79
+    }
80 80
 
81
-	/**
82
-	 * @param IOutput $output
83
-	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
84
-	 * @param array $options
85
-	 */
86
-	public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
87
-		/** @var ISchemaWrapper $schema */
88
-		$schema = $schemaClosure();
81
+    /**
82
+     * @param IOutput $output
83
+     * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
84
+     * @param array $options
85
+     */
86
+    public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
87
+        /** @var ISchemaWrapper $schema */
88
+        $schema = $schemaClosure();
89 89
 
90
-		if (!$schema->hasTable('ldap_group_mapping_backup')) {
91
-			// Backup table does not exist
92
-			return;
93
-		}
90
+        if (!$schema->hasTable('ldap_group_mapping_backup')) {
91
+            // Backup table does not exist
92
+            return;
93
+        }
94 94
 
95
-		$output->startProgress();
96
-		$this->copyGroupMappingData('ldap_group_mapping_backup', 'ldap_group_mapping');
97
-		$output->finishProgress();
98
-	}
95
+        $output->startProgress();
96
+        $this->copyGroupMappingData('ldap_group_mapping_backup', 'ldap_group_mapping');
97
+        $output->finishProgress();
98
+    }
99 99
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/Migration/Version1010Date20200630192842.php 1 patch
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -33,80 +33,80 @@
 block discarded – undo
33 33
 use OCP\Migration\SimpleMigrationStep;
34 34
 
35 35
 class Version1010Date20200630192842 extends SimpleMigrationStep {
36
-	/**
37
-	 * @param IOutput $output
38
-	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
39
-	 * @param array $options
40
-	 * @return null|ISchemaWrapper
41
-	 */
42
-	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
43
-		/** @var ISchemaWrapper $schema */
44
-		$schema = $schemaClosure();
36
+    /**
37
+     * @param IOutput $output
38
+     * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
39
+     * @param array $options
40
+     * @return null|ISchemaWrapper
41
+     */
42
+    public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
43
+        /** @var ISchemaWrapper $schema */
44
+        $schema = $schemaClosure();
45 45
 
46
-		if (!$schema->hasTable('ldap_user_mapping')) {
47
-			$table = $schema->createTable('ldap_user_mapping');
48
-			$table->addColumn('ldap_dn', Types::STRING, [
49
-				'notnull' => true,
50
-				'length' => 4000,
51
-				'default' => '',
52
-			]);
53
-			$table->addColumn('owncloud_name', Types::STRING, [
54
-				'notnull' => true,
55
-				'length' => 64,
56
-				'default' => '',
57
-			]);
58
-			$table->addColumn('directory_uuid', Types::STRING, [
59
-				'notnull' => true,
60
-				'length' => 255,
61
-				'default' => '',
62
-			]);
63
-			$table->addColumn('ldap_dn_hash', Types::STRING, [
64
-				'notnull' => false,
65
-				'length' => 64,
66
-			]);
67
-			$table->setPrimaryKey(['owncloud_name']);
68
-			$table->addUniqueIndex(['ldap_dn_hash'], 'ldap_user_dn_hashes');
69
-			$table->addUniqueIndex(['directory_uuid'], 'ldap_user_directory_uuid');
70
-		}
46
+        if (!$schema->hasTable('ldap_user_mapping')) {
47
+            $table = $schema->createTable('ldap_user_mapping');
48
+            $table->addColumn('ldap_dn', Types::STRING, [
49
+                'notnull' => true,
50
+                'length' => 4000,
51
+                'default' => '',
52
+            ]);
53
+            $table->addColumn('owncloud_name', Types::STRING, [
54
+                'notnull' => true,
55
+                'length' => 64,
56
+                'default' => '',
57
+            ]);
58
+            $table->addColumn('directory_uuid', Types::STRING, [
59
+                'notnull' => true,
60
+                'length' => 255,
61
+                'default' => '',
62
+            ]);
63
+            $table->addColumn('ldap_dn_hash', Types::STRING, [
64
+                'notnull' => false,
65
+                'length' => 64,
66
+            ]);
67
+            $table->setPrimaryKey(['owncloud_name']);
68
+            $table->addUniqueIndex(['ldap_dn_hash'], 'ldap_user_dn_hashes');
69
+            $table->addUniqueIndex(['directory_uuid'], 'ldap_user_directory_uuid');
70
+        }
71 71
 
72
-		if (!$schema->hasTable('ldap_group_mapping')) {
73
-			$table = $schema->createTable('ldap_group_mapping');
74
-			$table->addColumn('ldap_dn', Types::STRING, [
75
-				'notnull' => true,
76
-				'length' => 4000,
77
-				'default' => '',
78
-			]);
79
-			$table->addColumn('owncloud_name', Types::STRING, [
80
-				'notnull' => true,
81
-				'length' => 64,
82
-				'default' => '',
83
-			]);
84
-			$table->addColumn('directory_uuid', Types::STRING, [
85
-				'notnull' => true,
86
-				'length' => 255,
87
-				'default' => '',
88
-			]);
89
-			$table->addColumn('ldap_dn_hash', Types::STRING, [
90
-				'notnull' => false,
91
-				'length' => 64,
92
-			]);
93
-			$table->setPrimaryKey(['owncloud_name']);
94
-			$table->addUniqueIndex(['ldap_dn_hash'], 'ldap_group_dn_hashes');
95
-			$table->addUniqueIndex(['directory_uuid'], 'ldap_group_directory_uuid');
96
-		}
72
+        if (!$schema->hasTable('ldap_group_mapping')) {
73
+            $table = $schema->createTable('ldap_group_mapping');
74
+            $table->addColumn('ldap_dn', Types::STRING, [
75
+                'notnull' => true,
76
+                'length' => 4000,
77
+                'default' => '',
78
+            ]);
79
+            $table->addColumn('owncloud_name', Types::STRING, [
80
+                'notnull' => true,
81
+                'length' => 64,
82
+                'default' => '',
83
+            ]);
84
+            $table->addColumn('directory_uuid', Types::STRING, [
85
+                'notnull' => true,
86
+                'length' => 255,
87
+                'default' => '',
88
+            ]);
89
+            $table->addColumn('ldap_dn_hash', Types::STRING, [
90
+                'notnull' => false,
91
+                'length' => 64,
92
+            ]);
93
+            $table->setPrimaryKey(['owncloud_name']);
94
+            $table->addUniqueIndex(['ldap_dn_hash'], 'ldap_group_dn_hashes');
95
+            $table->addUniqueIndex(['directory_uuid'], 'ldap_group_directory_uuid');
96
+        }
97 97
 
98
-		if (!$schema->hasTable('ldap_group_members')) {
99
-			$table = $schema->createTable('ldap_group_members');
100
-			$table->addColumn('owncloudname', Types::STRING, [
101
-				'notnull' => true,
102
-				'length' => 255,
103
-				'default' => '',
104
-			]);
105
-			$table->addColumn('owncloudusers', Types::TEXT, [
106
-				'notnull' => true,
107
-			]);
108
-			$table->setPrimaryKey(['owncloudname']);
109
-		}
110
-		return $schema;
111
-	}
98
+        if (!$schema->hasTable('ldap_group_members')) {
99
+            $table = $schema->createTable('ldap_group_members');
100
+            $table->addColumn('owncloudname', Types::STRING, [
101
+                'notnull' => true,
102
+                'length' => 255,
103
+                'default' => '',
104
+            ]);
105
+            $table->addColumn('owncloudusers', Types::TEXT, [
106
+                'notnull' => true,
107
+            ]);
108
+            $table->setPrimaryKey(['owncloudname']);
109
+        }
110
+        return $schema;
111
+    }
112 112
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Migration/Version1016Date20220324154536.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -31,24 +31,24 @@
 block discarded – undo
31 31
 
32 32
 class Version1016Date20220324154536 extends SimpleMigrationStep {
33 33
 
34
-	/**
35
-	 * @param IOutput $output
36
-	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
37
-	 * @param array $options
38
-	 * @return null|ISchemaWrapper
39
-	 */
40
-	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
41
-		/** @var ISchemaWrapper $schema */
42
-		$schema = $schemaClosure();
43
-
44
-		$table = $schema->getTable('external_config');
45
-		$column = $table->getColumn('value');
46
-
47
-		if ($column->getLength() > 4000) {
48
-			$column->setLength(4000);
49
-			return $schema;
50
-		}
51
-
52
-		return null;
53
-	}
34
+    /**
35
+     * @param IOutput $output
36
+     * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
37
+     * @param array $options
38
+     * @return null|ISchemaWrapper
39
+     */
40
+    public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
41
+        /** @var ISchemaWrapper $schema */
42
+        $schema = $schemaClosure();
43
+
44
+        $table = $schema->getTable('external_config');
45
+        $column = $table->getColumn('value');
46
+
47
+        if ($column->getLength() > 4000) {
48
+            $column->setLength(4000);
49
+            return $schema;
50
+        }
51
+
52
+        return null;
53
+    }
54 54
 }
Please login to merge, or discard this patch.
lib/public/DataCollector/AbstractDataCollector.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -36,52 +36,52 @@
 block discarded – undo
36 36
  * @since 24.0.0
37 37
  */
38 38
 abstract class AbstractDataCollector implements IDataCollector, \JsonSerializable {
39
-	/** @var array */
40
-	protected $data = [];
39
+    /** @var array */
40
+    protected $data = [];
41 41
 
42
-	/**
43
-	 * @since 24.0.0
44
-	 */
45
-	public function getName(): string {
46
-		return static::class;
47
-	}
42
+    /**
43
+     * @since 24.0.0
44
+     */
45
+    public function getName(): string {
46
+        return static::class;
47
+    }
48 48
 
49
-	/**
50
-	 * Reset the state of the profiler. By default it only empties the
51
-	 * $this->data contents, but you can override this method to do
52
-	 * additional cleaning.
53
-	 * @since 24.0.0
54
-	 */
55
-	public function reset(): void {
56
-		$this->data = [];
57
-	}
49
+    /**
50
+     * Reset the state of the profiler. By default it only empties the
51
+     * $this->data contents, but you can override this method to do
52
+     * additional cleaning.
53
+     * @since 24.0.0
54
+     */
55
+    public function reset(): void {
56
+        $this->data = [];
57
+    }
58 58
 
59
-	/**
60
-	 * @since 24.0.0
61
-	 */
62
-	public function __sleep(): array {
63
-		return ['data'];
64
-	}
59
+    /**
60
+     * @since 24.0.0
61
+     */
62
+    public function __sleep(): array {
63
+        return ['data'];
64
+    }
65 65
 
66
-	/**
67
-	 * @internal to prevent implementing \Serializable
68
-	 * @since 24.0.0
69
-	 */
70
-	final protected function serialize() {
71
-	}
66
+    /**
67
+     * @internal to prevent implementing \Serializable
68
+     * @since 24.0.0
69
+     */
70
+    final protected function serialize() {
71
+    }
72 72
 
73
-	/**
74
-	 * @internal to prevent implementing \Serializable
75
-	 * @since 24.0.0
76
-	 */
77
-	final protected function unserialize(string $data) {
78
-	}
73
+    /**
74
+     * @internal to prevent implementing \Serializable
75
+     * @since 24.0.0
76
+     */
77
+    final protected function unserialize(string $data) {
78
+    }
79 79
 
80
-	/**
81
-	 * @since 24.0.0
82
-	 */
83
-	#[\ReturnTypeWillChange]
84
-	public function jsonSerialize() {
85
-		return $this->data;
86
-	}
80
+    /**
81
+     * @since 24.0.0
82
+     */
83
+    #[\ReturnTypeWillChange]
84
+    public function jsonSerialize() {
85
+        return $this->data;
86
+    }
87 87
 }
Please login to merge, or discard this patch.
lib/public/Profiler/IProfile.php 1 patch
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -42,127 +42,127 @@
 block discarded – undo
42 42
  * @since 24.0.0
43 43
  */
44 44
 interface IProfile {
45
-	/**
46
-	 * Get the token of the profile
47
-	 * @since 24.0.0
48
-	 */
49
-	public function getToken(): string;
50
-
51
-	/**
52
-	 * Set the token of the profile
53
-	 * @since 24.0.0
54
-	 */
55
-	public function setToken(string $token): void;
56
-
57
-	/**
58
-	 * Get the time of the profile
59
-	 * @since 24.0.0
60
-	 */
61
-	public function getTime(): ?int;
62
-
63
-	/**
64
-	 * Set the time of the profile
65
-	 * @since 24.0.0
66
-	 */
67
-	public function setTime(int $time): void;
68
-
69
-	/**
70
-	 * Get the url of the profile
71
-	 * @since 24.0.0
72
-	 */
73
-	public function getUrl(): ?string;
74
-
75
-	/**
76
-	 * Set the url of the profile
77
-	 * @since 24.0.0
78
-	 */
79
-	public function setUrl(string $url): void;
80
-
81
-	/**
82
-	 * Get the method of the profile
83
-	 * @since 24.0.0
84
-	 */
85
-	public function getMethod(): ?string;
86
-
87
-	/**
88
-	 * Set the method of the profile
89
-	 * @since 24.0.0
90
-	 */
91
-	public function setMethod(string $method): void;
92
-
93
-	/**
94
-	 * Get the status code of the profile
95
-	 * @since 24.0.0
96
-	 */
97
-	public function getStatusCode(): ?int;
98
-
99
-	/**
100
-	 * Set the status code of the profile
101
-	 * @since 24.0.0
102
-	 */
103
-	public function setStatusCode(int $statusCode): void;
104
-
105
-	/**
106
-	 * Add a data collector to the profile
107
-	 * @since 24.0.0
108
-	 */
109
-	public function addCollector(IDataCollector $collector);
110
-
111
-	/**
112
-	 * Get the parent profile to this profile
113
-	 * @since 24.0.0
114
-	 */
115
-	public function getParent(): ?IProfile;
116
-
117
-	/**
118
-	 * Set the parent profile to this profile
119
-	 * @since 24.0.0
120
-	 */
121
-	public function setParent(?IProfile $parent): void;
122
-
123
-	/**
124
-	 * Get the parent token to this profile
125
-	 * @since 24.0.0
126
-	 */
127
-	public function getParentToken(): ?string;
128
-
129
-	/**
130
-	 * Get the profile's children
131
-	 * @return IProfile[]
132
-	 * @since 24.0.0
133
-	 **/
134
-	public function getChildren(): array;
135
-
136
-	/**
137
-	 * Set the profile's children
138
-	 * @param IProfile[] $children
139
-	 * @since 24.0.0
140
-	 */
141
-	public function setChildren(array $children): void;
142
-
143
-	/**
144
-	 * Add the child profile
145
-	 * @since 24.0.0
146
-	 */
147
-	public function addChild(IProfile $profile): void;
148
-
149
-	/**
150
-	 * Get all the data collectors
151
-	 * @return IDataCollector[]
152
-	 * @since 24.0.0
153
-	 */
154
-	public function getCollectors(): array;
155
-
156
-	/**
157
-	 * Set all the data collectors
158
-	 * @param IDataCollector[] $collectors
159
-	 * @since 24.0.0
160
-	 */
161
-	public function setCollectors(array $collectors): void;
162
-
163
-	/**
164
-	 * Get a data collector by name
165
-	 * @since 24.0.0
166
-	 */
167
-	public function getCollector(string $collectorName): ?IDataCollector;
45
+    /**
46
+     * Get the token of the profile
47
+     * @since 24.0.0
48
+     */
49
+    public function getToken(): string;
50
+
51
+    /**
52
+     * Set the token of the profile
53
+     * @since 24.0.0
54
+     */
55
+    public function setToken(string $token): void;
56
+
57
+    /**
58
+     * Get the time of the profile
59
+     * @since 24.0.0
60
+     */
61
+    public function getTime(): ?int;
62
+
63
+    /**
64
+     * Set the time of the profile
65
+     * @since 24.0.0
66
+     */
67
+    public function setTime(int $time): void;
68
+
69
+    /**
70
+     * Get the url of the profile
71
+     * @since 24.0.0
72
+     */
73
+    public function getUrl(): ?string;
74
+
75
+    /**
76
+     * Set the url of the profile
77
+     * @since 24.0.0
78
+     */
79
+    public function setUrl(string $url): void;
80
+
81
+    /**
82
+     * Get the method of the profile
83
+     * @since 24.0.0
84
+     */
85
+    public function getMethod(): ?string;
86
+
87
+    /**
88
+     * Set the method of the profile
89
+     * @since 24.0.0
90
+     */
91
+    public function setMethod(string $method): void;
92
+
93
+    /**
94
+     * Get the status code of the profile
95
+     * @since 24.0.0
96
+     */
97
+    public function getStatusCode(): ?int;
98
+
99
+    /**
100
+     * Set the status code of the profile
101
+     * @since 24.0.0
102
+     */
103
+    public function setStatusCode(int $statusCode): void;
104
+
105
+    /**
106
+     * Add a data collector to the profile
107
+     * @since 24.0.0
108
+     */
109
+    public function addCollector(IDataCollector $collector);
110
+
111
+    /**
112
+     * Get the parent profile to this profile
113
+     * @since 24.0.0
114
+     */
115
+    public function getParent(): ?IProfile;
116
+
117
+    /**
118
+     * Set the parent profile to this profile
119
+     * @since 24.0.0
120
+     */
121
+    public function setParent(?IProfile $parent): void;
122
+
123
+    /**
124
+     * Get the parent token to this profile
125
+     * @since 24.0.0
126
+     */
127
+    public function getParentToken(): ?string;
128
+
129
+    /**
130
+     * Get the profile's children
131
+     * @return IProfile[]
132
+     * @since 24.0.0
133
+     **/
134
+    public function getChildren(): array;
135
+
136
+    /**
137
+     * Set the profile's children
138
+     * @param IProfile[] $children
139
+     * @since 24.0.0
140
+     */
141
+    public function setChildren(array $children): void;
142
+
143
+    /**
144
+     * Add the child profile
145
+     * @since 24.0.0
146
+     */
147
+    public function addChild(IProfile $profile): void;
148
+
149
+    /**
150
+     * Get all the data collectors
151
+     * @return IDataCollector[]
152
+     * @since 24.0.0
153
+     */
154
+    public function getCollectors(): array;
155
+
156
+    /**
157
+     * Set all the data collectors
158
+     * @param IDataCollector[] $collectors
159
+     * @since 24.0.0
160
+     */
161
+    public function setCollectors(array $collectors): void;
162
+
163
+    /**
164
+     * Get a data collector by name
165
+     * @since 24.0.0
166
+     */
167
+    public function getCollector(string $collectorName): ?IDataCollector;
168 168
 }
Please login to merge, or discard this patch.
lib/private/DB/ObjectParameter.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -35,37 +35,37 @@
 block discarded – undo
35 35
 namespace OC\DB;
36 36
 
37 37
 final class ObjectParameter {
38
-	private $object;
39
-	private $error;
40
-	private $stringable;
41
-	private $class;
38
+    private $object;
39
+    private $error;
40
+    private $stringable;
41
+    private $class;
42 42
 
43
-	/**
44
-	 * @param object $object
45
-	 */
46
-	public function __construct($object, ?\Throwable $error) {
47
-		$this->object = $object;
48
-		$this->error = $error;
49
-		$this->stringable = \is_callable([$object, '__toString']);
50
-		$this->class = \get_class($object);
51
-	}
43
+    /**
44
+     * @param object $object
45
+     */
46
+    public function __construct($object, ?\Throwable $error) {
47
+        $this->object = $object;
48
+        $this->error = $error;
49
+        $this->stringable = \is_callable([$object, '__toString']);
50
+        $this->class = \get_class($object);
51
+    }
52 52
 
53
-	/**
54
-	 * @return object
55
-	 */
56
-	public function getObject() {
57
-		return $this->object;
58
-	}
53
+    /**
54
+     * @return object
55
+     */
56
+    public function getObject() {
57
+        return $this->object;
58
+    }
59 59
 
60
-	public function getError(): ?\Throwable {
61
-		return $this->error;
62
-	}
60
+    public function getError(): ?\Throwable {
61
+        return $this->error;
62
+    }
63 63
 
64
-	public function isStringable(): bool {
65
-		return $this->stringable;
66
-	}
64
+    public function isStringable(): bool {
65
+        return $this->stringable;
66
+    }
67 67
 
68
-	public function getClass(): string {
69
-		return $this->class;
70
-	}
68
+    public function getClass(): string {
69
+        return $this->class;
70
+    }
71 71
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 /**
5 5
  * This file is part of the Symfony package.
6 6
  *
Please login to merge, or discard this patch.