Passed
Push — master ( d95ccf...545de2 )
by Marcel
36:29 queued 18:36
created
lib/private/Repair/RepairInvalidShares.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 
72 72
 		$updatedEntries = $builder->execute();
73 73
 		if ($updatedEntries > 0) {
74
-			$out->info('Fixed file share permissions for ' . $updatedEntries . ' shares');
74
+			$out->info('Fixed file share permissions for '.$updatedEntries.' shares');
75 75
 		}
76 76
 	}
77 77
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 		}
108 108
 
109 109
 		if ($deletedEntries) {
110
-			$out->info('Removed ' . $deletedEntries . ' shares where the parent did not exist');
110
+			$out->info('Removed '.$deletedEntries.' shares where the parent did not exist');
111 111
 		}
112 112
 	}
113 113
 
Please login to merge, or discard this patch.
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -32,89 +32,89 @@
 block discarded – undo
32 32
  * Repairs shares with invalid data
33 33
  */
34 34
 class RepairInvalidShares implements IRepairStep {
35
-	public const CHUNK_SIZE = 200;
36
-
37
-	/** @var \OCP\IConfig */
38
-	protected $config;
39
-
40
-	/** @var \OCP\IDBConnection */
41
-	protected $connection;
42
-
43
-	/**
44
-	 * @param \OCP\IConfig $config
45
-	 * @param \OCP\IDBConnection $connection
46
-	 */
47
-	public function __construct($config, $connection) {
48
-		$this->connection = $connection;
49
-		$this->config = $config;
50
-	}
51
-
52
-	public function getName() {
53
-		return 'Repair invalid shares';
54
-	}
55
-
56
-	/**
57
-	 * Adjust file share permissions
58
-	 */
59
-	private function adjustFileSharePermissions(IOutput $out) {
60
-		$mask = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE;
61
-		$builder = $this->connection->getQueryBuilder();
62
-
63
-		$permsFunc = $builder->expr()->bitwiseAnd('permissions', $mask);
64
-		$builder
65
-			->update('share')
66
-			->set('permissions', $permsFunc)
67
-			->where($builder->expr()->eq('item_type', $builder->expr()->literal('file')))
68
-			->andWhere($builder->expr()->neq('permissions', $permsFunc));
69
-
70
-		$updatedEntries = $builder->execute();
71
-		if ($updatedEntries > 0) {
72
-			$out->info('Fixed file share permissions for ' . $updatedEntries . ' shares');
73
-		}
74
-	}
75
-
76
-	/**
77
-	 * Remove shares where the parent share does not exist anymore
78
-	 */
79
-	private function removeSharesNonExistingParent(IOutput $out) {
80
-		$deletedEntries = 0;
81
-
82
-		$query = $this->connection->getQueryBuilder();
83
-		$query->select('s1.parent')
84
-			->from('share', 's1')
85
-			->where($query->expr()->isNotNull('s1.parent'))
86
-				->andWhere($query->expr()->isNull('s2.id'))
87
-			->leftJoin('s1', 'share', 's2', $query->expr()->eq('s1.parent', 's2.id'))
88
-			->groupBy('s1.parent')
89
-			->setMaxResults(self::CHUNK_SIZE);
90
-
91
-		$deleteQuery = $this->connection->getQueryBuilder();
92
-		$deleteQuery->delete('share')
93
-			->where($deleteQuery->expr()->eq('parent', $deleteQuery->createParameter('parent')));
94
-
95
-		$deletedInLastChunk = self::CHUNK_SIZE;
96
-		while ($deletedInLastChunk === self::CHUNK_SIZE) {
97
-			$deletedInLastChunk = 0;
98
-			$result = $query->execute();
99
-			while ($row = $result->fetch()) {
100
-				$deletedInLastChunk++;
101
-				$deletedEntries += $deleteQuery->setParameter('parent', (int) $row['parent'])
102
-					->execute();
103
-			}
104
-			$result->closeCursor();
105
-		}
106
-
107
-		if ($deletedEntries) {
108
-			$out->info('Removed ' . $deletedEntries . ' shares where the parent did not exist');
109
-		}
110
-	}
111
-
112
-	public function run(IOutput $out) {
113
-		$ocVersionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0');
114
-		if (version_compare($ocVersionFromBeforeUpdate, '12.0.0.11', '<')) {
115
-			$this->adjustFileSharePermissions($out);
116
-		}
117
-
118
-		$this->removeSharesNonExistingParent($out);
119
-	}
35
+    public const CHUNK_SIZE = 200;
36
+
37
+    /** @var \OCP\IConfig */
38
+    protected $config;
39
+
40
+    /** @var \OCP\IDBConnection */
41
+    protected $connection;
42
+
43
+    /**
44
+     * @param \OCP\IConfig $config
45
+     * @param \OCP\IDBConnection $connection
46
+     */
47
+    public function __construct($config, $connection) {
48
+        $this->connection = $connection;
49
+        $this->config = $config;
50
+    }
51
+
52
+    public function getName() {
53
+        return 'Repair invalid shares';
54
+    }
55
+
56
+    /**
57
+     * Adjust file share permissions
58
+     */
59
+    private function adjustFileSharePermissions(IOutput $out) {
60
+        $mask = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE;
61
+        $builder = $this->connection->getQueryBuilder();
62
+
63
+        $permsFunc = $builder->expr()->bitwiseAnd('permissions', $mask);
64
+        $builder
65
+            ->update('share')
66
+            ->set('permissions', $permsFunc)
67
+            ->where($builder->expr()->eq('item_type', $builder->expr()->literal('file')))
68
+            ->andWhere($builder->expr()->neq('permissions', $permsFunc));
69
+
70
+        $updatedEntries = $builder->execute();
71
+        if ($updatedEntries > 0) {
72
+            $out->info('Fixed file share permissions for ' . $updatedEntries . ' shares');
73
+        }
74
+    }
75
+
76
+    /**
77
+     * Remove shares where the parent share does not exist anymore
78
+     */
79
+    private function removeSharesNonExistingParent(IOutput $out) {
80
+        $deletedEntries = 0;
81
+
82
+        $query = $this->connection->getQueryBuilder();
83
+        $query->select('s1.parent')
84
+            ->from('share', 's1')
85
+            ->where($query->expr()->isNotNull('s1.parent'))
86
+                ->andWhere($query->expr()->isNull('s2.id'))
87
+            ->leftJoin('s1', 'share', 's2', $query->expr()->eq('s1.parent', 's2.id'))
88
+            ->groupBy('s1.parent')
89
+            ->setMaxResults(self::CHUNK_SIZE);
90
+
91
+        $deleteQuery = $this->connection->getQueryBuilder();
92
+        $deleteQuery->delete('share')
93
+            ->where($deleteQuery->expr()->eq('parent', $deleteQuery->createParameter('parent')));
94
+
95
+        $deletedInLastChunk = self::CHUNK_SIZE;
96
+        while ($deletedInLastChunk === self::CHUNK_SIZE) {
97
+            $deletedInLastChunk = 0;
98
+            $result = $query->execute();
99
+            while ($row = $result->fetch()) {
100
+                $deletedInLastChunk++;
101
+                $deletedEntries += $deleteQuery->setParameter('parent', (int) $row['parent'])
102
+                    ->execute();
103
+            }
104
+            $result->closeCursor();
105
+        }
106
+
107
+        if ($deletedEntries) {
108
+            $out->info('Removed ' . $deletedEntries . ' shares where the parent did not exist');
109
+        }
110
+    }
111
+
112
+    public function run(IOutput $out) {
113
+        $ocVersionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0');
114
+        if (version_compare($ocVersionFromBeforeUpdate, '12.0.0.11', '<')) {
115
+            $this->adjustFileSharePermissions($out);
116
+        }
117
+
118
+        $this->removeSharesNonExistingParent($out);
119
+    }
120 120
 }
Please login to merge, or discard this patch.
apps/dav/appinfo/v2/remote.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
  */
22 22
 // no php execution timeout for webdav
23 23
 if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
24
-	@set_time_limit(0);
24
+    @set_time_limit(0);
25 25
 }
26 26
 ignore_user_abort(true);
27 27
 
Please login to merge, or discard this patch.
lib/private/Share20/ProviderFactory.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 		}
215 215
 
216 216
 		if ($provider === null) {
217
-			throw new ProviderException('No provider with id .' . $id . ' found.');
217
+			throw new ProviderException('No provider with id .'.$id.' found.');
218 218
 		}
219 219
 
220 220
 		return $provider;
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 
242 242
 
243 243
 		if ($provider === null) {
244
-			throw new ProviderException('No share provider for share type ' . $shareType);
244
+			throw new ProviderException('No share provider for share type '.$shareType);
245 245
 		}
246 246
 
247 247
 		return $provider;
Please login to merge, or discard this patch.
Indentation   +324 added lines, -324 removed lines patch added patch discarded remove patch
@@ -56,337 +56,337 @@
 block discarded – undo
56 56
  * @package OC\Share20
57 57
  */
58 58
 class ProviderFactory implements IProviderFactory {
59
-	/** @var IServerContainer */
60
-	private $serverContainer;
61
-	/** @var DefaultShareProvider */
62
-	private $defaultProvider = null;
63
-	/** @var FederatedShareProvider */
64
-	private $federatedProvider = null;
65
-	/** @var  ShareByMailProvider */
66
-	private $shareByMailProvider;
67
-	/** @var  \OCA\Circles\ShareByCircleProvider */
68
-	private $shareByCircleProvider = null;
69
-	/** @var bool */
70
-	private $circlesAreNotAvailable = false;
71
-	/** @var \OCA\Talk\Share\RoomShareProvider */
72
-	private $roomShareProvider = null;
73
-
74
-	private $registeredShareProviders = [];
75
-
76
-	private $shareProviders = [];
77
-
78
-	/**
79
-	 * IProviderFactory constructor.
80
-	 *
81
-	 * @param IServerContainer $serverContainer
82
-	 */
83
-	public function __construct(IServerContainer $serverContainer) {
84
-		$this->serverContainer = $serverContainer;
85
-	}
86
-
87
-	public function registerProvider(string $shareProviderClass): void {
88
-		$this->registeredShareProviders[] = $shareProviderClass;
89
-	}
90
-
91
-	/**
92
-	 * Create the default share provider.
93
-	 *
94
-	 * @return DefaultShareProvider
95
-	 */
96
-	protected function defaultShareProvider() {
97
-		if ($this->defaultProvider === null) {
98
-			$this->defaultProvider = new DefaultShareProvider(
99
-				$this->serverContainer->getDatabaseConnection(),
100
-				$this->serverContainer->getUserManager(),
101
-				$this->serverContainer->getGroupManager(),
102
-				$this->serverContainer->getLazyRootFolder(),
103
-				$this->serverContainer->getMailer(),
104
-				$this->serverContainer->query(Defaults::class),
105
-				$this->serverContainer->getL10NFactory(),
106
-				$this->serverContainer->getURLGenerator(),
107
-				$this->serverContainer->getConfig()
108
-			);
109
-		}
110
-
111
-		return $this->defaultProvider;
112
-	}
113
-
114
-	/**
115
-	 * Create the federated share provider
116
-	 *
117
-	 * @return FederatedShareProvider
118
-	 */
119
-	protected function federatedShareProvider() {
120
-		if ($this->federatedProvider === null) {
121
-			/*
59
+    /** @var IServerContainer */
60
+    private $serverContainer;
61
+    /** @var DefaultShareProvider */
62
+    private $defaultProvider = null;
63
+    /** @var FederatedShareProvider */
64
+    private $federatedProvider = null;
65
+    /** @var  ShareByMailProvider */
66
+    private $shareByMailProvider;
67
+    /** @var  \OCA\Circles\ShareByCircleProvider */
68
+    private $shareByCircleProvider = null;
69
+    /** @var bool */
70
+    private $circlesAreNotAvailable = false;
71
+    /** @var \OCA\Talk\Share\RoomShareProvider */
72
+    private $roomShareProvider = null;
73
+
74
+    private $registeredShareProviders = [];
75
+
76
+    private $shareProviders = [];
77
+
78
+    /**
79
+     * IProviderFactory constructor.
80
+     *
81
+     * @param IServerContainer $serverContainer
82
+     */
83
+    public function __construct(IServerContainer $serverContainer) {
84
+        $this->serverContainer = $serverContainer;
85
+    }
86
+
87
+    public function registerProvider(string $shareProviderClass): void {
88
+        $this->registeredShareProviders[] = $shareProviderClass;
89
+    }
90
+
91
+    /**
92
+     * Create the default share provider.
93
+     *
94
+     * @return DefaultShareProvider
95
+     */
96
+    protected function defaultShareProvider() {
97
+        if ($this->defaultProvider === null) {
98
+            $this->defaultProvider = new DefaultShareProvider(
99
+                $this->serverContainer->getDatabaseConnection(),
100
+                $this->serverContainer->getUserManager(),
101
+                $this->serverContainer->getGroupManager(),
102
+                $this->serverContainer->getLazyRootFolder(),
103
+                $this->serverContainer->getMailer(),
104
+                $this->serverContainer->query(Defaults::class),
105
+                $this->serverContainer->getL10NFactory(),
106
+                $this->serverContainer->getURLGenerator(),
107
+                $this->serverContainer->getConfig()
108
+            );
109
+        }
110
+
111
+        return $this->defaultProvider;
112
+    }
113
+
114
+    /**
115
+     * Create the federated share provider
116
+     *
117
+     * @return FederatedShareProvider
118
+     */
119
+    protected function federatedShareProvider() {
120
+        if ($this->federatedProvider === null) {
121
+            /*
122 122
 			 * Check if the app is enabled
123 123
 			 */
124
-			$appManager = $this->serverContainer->getAppManager();
125
-			if (!$appManager->isEnabledForUser('federatedfilesharing')) {
126
-				return null;
127
-			}
124
+            $appManager = $this->serverContainer->getAppManager();
125
+            if (!$appManager->isEnabledForUser('federatedfilesharing')) {
126
+                return null;
127
+            }
128 128
 
129
-			/*
129
+            /*
130 130
 			 * TODO: add factory to federated sharing app
131 131
 			 */
132
-			$l = $this->serverContainer->getL10N('federatedfilesharing');
133
-			$addressHandler = new AddressHandler(
134
-				$this->serverContainer->getURLGenerator(),
135
-				$l,
136
-				$this->serverContainer->getCloudIdManager()
137
-			);
138
-			$notifications = new Notifications(
139
-				$addressHandler,
140
-				$this->serverContainer->getHTTPClientService(),
141
-				$this->serverContainer->query(\OCP\OCS\IDiscoveryService::class),
142
-				$this->serverContainer->getLogger(),
143
-				$this->serverContainer->getJobList(),
144
-				\OC::$server->getCloudFederationProviderManager(),
145
-				\OC::$server->getCloudFederationFactory(),
146
-				$this->serverContainer->query(IEventDispatcher::class)
147
-			);
148
-			$tokenHandler = new TokenHandler(
149
-				$this->serverContainer->getSecureRandom()
150
-			);
151
-
152
-			$this->federatedProvider = new FederatedShareProvider(
153
-				$this->serverContainer->getDatabaseConnection(),
154
-				$addressHandler,
155
-				$notifications,
156
-				$tokenHandler,
157
-				$l,
158
-				$this->serverContainer->getLogger(),
159
-				$this->serverContainer->getLazyRootFolder(),
160
-				$this->serverContainer->getConfig(),
161
-				$this->serverContainer->getUserManager(),
162
-				$this->serverContainer->getCloudIdManager(),
163
-				$this->serverContainer->getGlobalScaleConfig(),
164
-				$this->serverContainer->getCloudFederationProviderManager()
165
-			);
166
-		}
167
-
168
-		return $this->federatedProvider;
169
-	}
170
-
171
-	/**
172
-	 * Create the federated share provider
173
-	 *
174
-	 * @return ShareByMailProvider
175
-	 */
176
-	protected function getShareByMailProvider() {
177
-		if ($this->shareByMailProvider === null) {
178
-			/*
132
+            $l = $this->serverContainer->getL10N('federatedfilesharing');
133
+            $addressHandler = new AddressHandler(
134
+                $this->serverContainer->getURLGenerator(),
135
+                $l,
136
+                $this->serverContainer->getCloudIdManager()
137
+            );
138
+            $notifications = new Notifications(
139
+                $addressHandler,
140
+                $this->serverContainer->getHTTPClientService(),
141
+                $this->serverContainer->query(\OCP\OCS\IDiscoveryService::class),
142
+                $this->serverContainer->getLogger(),
143
+                $this->serverContainer->getJobList(),
144
+                \OC::$server->getCloudFederationProviderManager(),
145
+                \OC::$server->getCloudFederationFactory(),
146
+                $this->serverContainer->query(IEventDispatcher::class)
147
+            );
148
+            $tokenHandler = new TokenHandler(
149
+                $this->serverContainer->getSecureRandom()
150
+            );
151
+
152
+            $this->federatedProvider = new FederatedShareProvider(
153
+                $this->serverContainer->getDatabaseConnection(),
154
+                $addressHandler,
155
+                $notifications,
156
+                $tokenHandler,
157
+                $l,
158
+                $this->serverContainer->getLogger(),
159
+                $this->serverContainer->getLazyRootFolder(),
160
+                $this->serverContainer->getConfig(),
161
+                $this->serverContainer->getUserManager(),
162
+                $this->serverContainer->getCloudIdManager(),
163
+                $this->serverContainer->getGlobalScaleConfig(),
164
+                $this->serverContainer->getCloudFederationProviderManager()
165
+            );
166
+        }
167
+
168
+        return $this->federatedProvider;
169
+    }
170
+
171
+    /**
172
+     * Create the federated share provider
173
+     *
174
+     * @return ShareByMailProvider
175
+     */
176
+    protected function getShareByMailProvider() {
177
+        if ($this->shareByMailProvider === null) {
178
+            /*
179 179
 			 * Check if the app is enabled
180 180
 			 */
181
-			$appManager = $this->serverContainer->getAppManager();
182
-			if (!$appManager->isEnabledForUser('sharebymail')) {
183
-				return null;
184
-			}
185
-
186
-			$settingsManager = new SettingsManager($this->serverContainer->getConfig());
187
-
188
-			$this->shareByMailProvider = new ShareByMailProvider(
189
-				$this->serverContainer->getConfig(),
190
-				$this->serverContainer->getDatabaseConnection(),
191
-				$this->serverContainer->getSecureRandom(),
192
-				$this->serverContainer->getUserManager(),
193
-				$this->serverContainer->getLazyRootFolder(),
194
-				$this->serverContainer->getL10N('sharebymail'),
195
-				$this->serverContainer->getLogger(),
196
-				$this->serverContainer->getMailer(),
197
-				$this->serverContainer->getURLGenerator(),
198
-				$this->serverContainer->getActivityManager(),
199
-				$settingsManager,
200
-				$this->serverContainer->query(Defaults::class),
201
-				$this->serverContainer->getHasher(),
202
-				$this->serverContainer->get(IEventDispatcher::class),
203
-				$this->serverContainer->get(IManager::class)
204
-			);
205
-		}
206
-
207
-		return $this->shareByMailProvider;
208
-	}
209
-
210
-
211
-	/**
212
-	 * Create the circle share provider
213
-	 *
214
-	 * @return FederatedShareProvider
215
-	 *
216
-	 * @suppress PhanUndeclaredClassMethod
217
-	 */
218
-	protected function getShareByCircleProvider() {
219
-		if ($this->circlesAreNotAvailable) {
220
-			return null;
221
-		}
222
-
223
-		if (!$this->serverContainer->getAppManager()->isEnabledForUser('circles') ||
224
-			!class_exists('\OCA\Circles\ShareByCircleProvider')
225
-		) {
226
-			$this->circlesAreNotAvailable = true;
227
-			return null;
228
-		}
229
-
230
-		if ($this->shareByCircleProvider === null) {
231
-			$this->shareByCircleProvider = new \OCA\Circles\ShareByCircleProvider(
232
-				$this->serverContainer->getDatabaseConnection(),
233
-				$this->serverContainer->getSecureRandom(),
234
-				$this->serverContainer->getUserManager(),
235
-				$this->serverContainer->getLazyRootFolder(),
236
-				$this->serverContainer->getL10N('circles'),
237
-				$this->serverContainer->getLogger(),
238
-				$this->serverContainer->getURLGenerator()
239
-			);
240
-		}
241
-
242
-		return $this->shareByCircleProvider;
243
-	}
244
-
245
-	/**
246
-	 * Create the room share provider
247
-	 *
248
-	 * @return RoomShareProvider
249
-	 */
250
-	protected function getRoomShareProvider() {
251
-		if ($this->roomShareProvider === null) {
252
-			/*
181
+            $appManager = $this->serverContainer->getAppManager();
182
+            if (!$appManager->isEnabledForUser('sharebymail')) {
183
+                return null;
184
+            }
185
+
186
+            $settingsManager = new SettingsManager($this->serverContainer->getConfig());
187
+
188
+            $this->shareByMailProvider = new ShareByMailProvider(
189
+                $this->serverContainer->getConfig(),
190
+                $this->serverContainer->getDatabaseConnection(),
191
+                $this->serverContainer->getSecureRandom(),
192
+                $this->serverContainer->getUserManager(),
193
+                $this->serverContainer->getLazyRootFolder(),
194
+                $this->serverContainer->getL10N('sharebymail'),
195
+                $this->serverContainer->getLogger(),
196
+                $this->serverContainer->getMailer(),
197
+                $this->serverContainer->getURLGenerator(),
198
+                $this->serverContainer->getActivityManager(),
199
+                $settingsManager,
200
+                $this->serverContainer->query(Defaults::class),
201
+                $this->serverContainer->getHasher(),
202
+                $this->serverContainer->get(IEventDispatcher::class),
203
+                $this->serverContainer->get(IManager::class)
204
+            );
205
+        }
206
+
207
+        return $this->shareByMailProvider;
208
+    }
209
+
210
+
211
+    /**
212
+     * Create the circle share provider
213
+     *
214
+     * @return FederatedShareProvider
215
+     *
216
+     * @suppress PhanUndeclaredClassMethod
217
+     */
218
+    protected function getShareByCircleProvider() {
219
+        if ($this->circlesAreNotAvailable) {
220
+            return null;
221
+        }
222
+
223
+        if (!$this->serverContainer->getAppManager()->isEnabledForUser('circles') ||
224
+            !class_exists('\OCA\Circles\ShareByCircleProvider')
225
+        ) {
226
+            $this->circlesAreNotAvailable = true;
227
+            return null;
228
+        }
229
+
230
+        if ($this->shareByCircleProvider === null) {
231
+            $this->shareByCircleProvider = new \OCA\Circles\ShareByCircleProvider(
232
+                $this->serverContainer->getDatabaseConnection(),
233
+                $this->serverContainer->getSecureRandom(),
234
+                $this->serverContainer->getUserManager(),
235
+                $this->serverContainer->getLazyRootFolder(),
236
+                $this->serverContainer->getL10N('circles'),
237
+                $this->serverContainer->getLogger(),
238
+                $this->serverContainer->getURLGenerator()
239
+            );
240
+        }
241
+
242
+        return $this->shareByCircleProvider;
243
+    }
244
+
245
+    /**
246
+     * Create the room share provider
247
+     *
248
+     * @return RoomShareProvider
249
+     */
250
+    protected function getRoomShareProvider() {
251
+        if ($this->roomShareProvider === null) {
252
+            /*
253 253
 			 * Check if the app is enabled
254 254
 			 */
255
-			$appManager = $this->serverContainer->getAppManager();
256
-			if (!$appManager->isEnabledForUser('spreed')) {
257
-				return null;
258
-			}
259
-
260
-			try {
261
-				/**
262
-				 * @psalm-suppress UndefinedClass
263
-				 */
264
-				$this->roomShareProvider = $this->serverContainer->get(RoomShareProvider::class);
265
-			} catch (\Throwable $e) {
266
-				$this->serverContainer->get(LoggerInterface::class)->error(
267
-					$e->getMessage(),
268
-					['exception' => $e]
269
-				);
270
-				return null;
271
-			}
272
-		}
273
-
274
-		return $this->roomShareProvider;
275
-	}
276
-
277
-	/**
278
-	 * @inheritdoc
279
-	 */
280
-	public function getProvider($id) {
281
-		$provider = null;
282
-		if (isset($this->shareProviders[$id])) {
283
-			return $this->shareProviders[$id];
284
-		}
285
-
286
-		if ($id === 'ocinternal') {
287
-			$provider = $this->defaultShareProvider();
288
-		} elseif ($id === 'ocFederatedSharing') {
289
-			$provider = $this->federatedShareProvider();
290
-		} elseif ($id === 'ocMailShare') {
291
-			$provider = $this->getShareByMailProvider();
292
-		} elseif ($id === 'ocCircleShare') {
293
-			$provider = $this->getShareByCircleProvider();
294
-		} elseif ($id === 'ocRoomShare') {
295
-			$provider = $this->getRoomShareProvider();
296
-		}
297
-
298
-		foreach ($this->registeredShareProviders as $shareProvider) {
299
-			try {
300
-				/** @var IShareProvider $instance */
301
-				$instance = $this->serverContainer->get($shareProvider);
302
-				$this->shareProviders[$instance->identifier()] = $instance;
303
-			} catch (\Throwable $e) {
304
-				$this->serverContainer->get(LoggerInterface::class)->error(
305
-					$e->getMessage(),
306
-					['exception' => $e]
307
-				);
308
-			}
309
-		}
310
-
311
-		if (isset($this->shareProviders[$id])) {
312
-			$provider = $this->shareProviders[$id];
313
-		}
314
-
315
-		if ($provider === null) {
316
-			throw new ProviderException('No provider with id .' . $id . ' found.');
317
-		}
318
-
319
-		return $provider;
320
-	}
321
-
322
-	/**
323
-	 * @inheritdoc
324
-	 */
325
-	public function getProviderForType($shareType) {
326
-		$provider = null;
327
-
328
-		if ($shareType === IShare::TYPE_USER ||
329
-			$shareType === IShare::TYPE_GROUP ||
330
-			$shareType === IShare::TYPE_LINK
331
-		) {
332
-			$provider = $this->defaultShareProvider();
333
-		} elseif ($shareType === IShare::TYPE_REMOTE || $shareType === IShare::TYPE_REMOTE_GROUP) {
334
-			$provider = $this->federatedShareProvider();
335
-		} elseif ($shareType === IShare::TYPE_EMAIL) {
336
-			$provider = $this->getShareByMailProvider();
337
-		} elseif ($shareType === IShare::TYPE_CIRCLE) {
338
-			$provider = $this->getShareByCircleProvider();
339
-		} elseif ($shareType === IShare::TYPE_ROOM) {
340
-			$provider = $this->getRoomShareProvider();
341
-		} elseif ($shareType === IShare::TYPE_DECK) {
342
-			$provider = $this->getProvider('deck');
343
-		} elseif ($shareType === IShare::TYPE_SCIENCEMESH) {
344
-			$provider = $this->getProvider('sciencemesh');
345
-		}
346
-
347
-
348
-		if ($provider === null) {
349
-			throw new ProviderException('No share provider for share type ' . $shareType);
350
-		}
351
-
352
-		return $provider;
353
-	}
354
-
355
-	public function getAllProviders() {
356
-		$shares = [$this->defaultShareProvider(), $this->federatedShareProvider()];
357
-		$shareByMail = $this->getShareByMailProvider();
358
-		if ($shareByMail !== null) {
359
-			$shares[] = $shareByMail;
360
-		}
361
-		$shareByCircle = $this->getShareByCircleProvider();
362
-		if ($shareByCircle !== null) {
363
-			$shares[] = $shareByCircle;
364
-		}
365
-		$roomShare = $this->getRoomShareProvider();
366
-		if ($roomShare !== null) {
367
-			$shares[] = $roomShare;
368
-		}
369
-
370
-		foreach ($this->registeredShareProviders as $shareProvider) {
371
-			try {
372
-				/** @var IShareProvider $instance */
373
-				$instance = $this->serverContainer->get($shareProvider);
374
-			} catch (\Throwable $e) {
375
-				$this->serverContainer->get(LoggerInterface::class)->error(
376
-					$e->getMessage(),
377
-					['exception' => $e]
378
-				);
379
-				continue;
380
-			}
381
-
382
-			if (!isset($this->shareProviders[$instance->identifier()])) {
383
-				$this->shareProviders[$instance->identifier()] = $instance;
384
-			}
385
-			$shares[] = $this->shareProviders[$instance->identifier()];
386
-		}
387
-
388
-
389
-
390
-		return $shares;
391
-	}
255
+            $appManager = $this->serverContainer->getAppManager();
256
+            if (!$appManager->isEnabledForUser('spreed')) {
257
+                return null;
258
+            }
259
+
260
+            try {
261
+                /**
262
+                 * @psalm-suppress UndefinedClass
263
+                 */
264
+                $this->roomShareProvider = $this->serverContainer->get(RoomShareProvider::class);
265
+            } catch (\Throwable $e) {
266
+                $this->serverContainer->get(LoggerInterface::class)->error(
267
+                    $e->getMessage(),
268
+                    ['exception' => $e]
269
+                );
270
+                return null;
271
+            }
272
+        }
273
+
274
+        return $this->roomShareProvider;
275
+    }
276
+
277
+    /**
278
+     * @inheritdoc
279
+     */
280
+    public function getProvider($id) {
281
+        $provider = null;
282
+        if (isset($this->shareProviders[$id])) {
283
+            return $this->shareProviders[$id];
284
+        }
285
+
286
+        if ($id === 'ocinternal') {
287
+            $provider = $this->defaultShareProvider();
288
+        } elseif ($id === 'ocFederatedSharing') {
289
+            $provider = $this->federatedShareProvider();
290
+        } elseif ($id === 'ocMailShare') {
291
+            $provider = $this->getShareByMailProvider();
292
+        } elseif ($id === 'ocCircleShare') {
293
+            $provider = $this->getShareByCircleProvider();
294
+        } elseif ($id === 'ocRoomShare') {
295
+            $provider = $this->getRoomShareProvider();
296
+        }
297
+
298
+        foreach ($this->registeredShareProviders as $shareProvider) {
299
+            try {
300
+                /** @var IShareProvider $instance */
301
+                $instance = $this->serverContainer->get($shareProvider);
302
+                $this->shareProviders[$instance->identifier()] = $instance;
303
+            } catch (\Throwable $e) {
304
+                $this->serverContainer->get(LoggerInterface::class)->error(
305
+                    $e->getMessage(),
306
+                    ['exception' => $e]
307
+                );
308
+            }
309
+        }
310
+
311
+        if (isset($this->shareProviders[$id])) {
312
+            $provider = $this->shareProviders[$id];
313
+        }
314
+
315
+        if ($provider === null) {
316
+            throw new ProviderException('No provider with id .' . $id . ' found.');
317
+        }
318
+
319
+        return $provider;
320
+    }
321
+
322
+    /**
323
+     * @inheritdoc
324
+     */
325
+    public function getProviderForType($shareType) {
326
+        $provider = null;
327
+
328
+        if ($shareType === IShare::TYPE_USER ||
329
+            $shareType === IShare::TYPE_GROUP ||
330
+            $shareType === IShare::TYPE_LINK
331
+        ) {
332
+            $provider = $this->defaultShareProvider();
333
+        } elseif ($shareType === IShare::TYPE_REMOTE || $shareType === IShare::TYPE_REMOTE_GROUP) {
334
+            $provider = $this->federatedShareProvider();
335
+        } elseif ($shareType === IShare::TYPE_EMAIL) {
336
+            $provider = $this->getShareByMailProvider();
337
+        } elseif ($shareType === IShare::TYPE_CIRCLE) {
338
+            $provider = $this->getShareByCircleProvider();
339
+        } elseif ($shareType === IShare::TYPE_ROOM) {
340
+            $provider = $this->getRoomShareProvider();
341
+        } elseif ($shareType === IShare::TYPE_DECK) {
342
+            $provider = $this->getProvider('deck');
343
+        } elseif ($shareType === IShare::TYPE_SCIENCEMESH) {
344
+            $provider = $this->getProvider('sciencemesh');
345
+        }
346
+
347
+
348
+        if ($provider === null) {
349
+            throw new ProviderException('No share provider for share type ' . $shareType);
350
+        }
351
+
352
+        return $provider;
353
+    }
354
+
355
+    public function getAllProviders() {
356
+        $shares = [$this->defaultShareProvider(), $this->federatedShareProvider()];
357
+        $shareByMail = $this->getShareByMailProvider();
358
+        if ($shareByMail !== null) {
359
+            $shares[] = $shareByMail;
360
+        }
361
+        $shareByCircle = $this->getShareByCircleProvider();
362
+        if ($shareByCircle !== null) {
363
+            $shares[] = $shareByCircle;
364
+        }
365
+        $roomShare = $this->getRoomShareProvider();
366
+        if ($roomShare !== null) {
367
+            $shares[] = $roomShare;
368
+        }
369
+
370
+        foreach ($this->registeredShareProviders as $shareProvider) {
371
+            try {
372
+                /** @var IShareProvider $instance */
373
+                $instance = $this->serverContainer->get($shareProvider);
374
+            } catch (\Throwable $e) {
375
+                $this->serverContainer->get(LoggerInterface::class)->error(
376
+                    $e->getMessage(),
377
+                    ['exception' => $e]
378
+                );
379
+                continue;
380
+            }
381
+
382
+            if (!isset($this->shareProviders[$instance->identifier()])) {
383
+                $this->shareProviders[$instance->identifier()] = $instance;
384
+            }
385
+            $shares[] = $this->shareProviders[$instance->identifier()];
386
+        }
387
+
388
+
389
+
390
+        return $shares;
391
+    }
392 392
 }
Please login to merge, or discard this patch.
apps/dav/lib/Avatars/RootCollection.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -7,23 +7,23 @@
 block discarded – undo
7 7
 
8 8
 class RootCollection extends AbstractPrincipalCollection {
9 9
 
10
-	/**
11
-	 * This method returns a node for a principal.
12
-	 *
13
-	 * The passed array contains principal information, and is guaranteed to
14
-	 * at least contain a uri item. Other properties may or may not be
15
-	 * supplied by the authentication backend.
16
-	 *
17
-	 * @param array $principalInfo
18
-	 * @return AvatarHome
19
-	 */
20
-	public function getChildForPrincipal(array $principalInfo) {
21
-		$avatarManager = \OC::$server->getAvatarManager();
22
-		return new AvatarHome($principalInfo, $avatarManager);
23
-	}
10
+    /**
11
+     * This method returns a node for a principal.
12
+     *
13
+     * The passed array contains principal information, and is guaranteed to
14
+     * at least contain a uri item. Other properties may or may not be
15
+     * supplied by the authentication backend.
16
+     *
17
+     * @param array $principalInfo
18
+     * @return AvatarHome
19
+     */
20
+    public function getChildForPrincipal(array $principalInfo) {
21
+        $avatarManager = \OC::$server->getAvatarManager();
22
+        return new AvatarHome($principalInfo, $avatarManager);
23
+    }
24 24
 
25
-	public function getName() {
26
-		return 'avatars';
27
-	}
25
+    public function getName() {
26
+        return 'avatars';
27
+    }
28 28
 
29 29
 }
Please login to merge, or discard this patch.
apps/dav/lib/Migration/CalDAVRemoveEmptyValue.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
 
66 66
 		$output->startProgress(count($objects));
67 67
 		foreach ($objects as $row) {
68
-			$calObject = $this->calDavBackend->getCalendarObject((int)$row['calendarid'], $row['uri']);
69
-			$data = preg_replace('/' . $pattern . '/', ':', $calObject['calendardata']);
68
+			$calObject = $this->calDavBackend->getCalendarObject((int) $row['calendarid'], $row['uri']);
69
+			$data = preg_replace('/'.$pattern.'/', ':', $calObject['calendardata']);
70 70
 
71 71
 			if ($data !== $calObject['calendardata']) {
72 72
 				$output->advance();
@@ -76,14 +76,14 @@  discard block
 block discarded – undo
76 76
 				} catch (InvalidDataException $e) {
77 77
 					$this->logger->info('Calendar object for calendar {cal} with uri {uri} still invalid', [
78 78
 						'app' => 'dav',
79
-						'cal' => (int)$row['calendarid'],
79
+						'cal' => (int) $row['calendarid'],
80 80
 						'uri' => $row['uri'],
81 81
 					]);
82 82
 					$warnings++;
83 83
 					continue;
84 84
 				}
85 85
 
86
-				$this->calDavBackend->updateCalendarObject((int)$row['calendarid'], $row['uri'], $data);
86
+				$this->calDavBackend->updateCalendarObject((int) $row['calendarid'], $row['uri'], $data);
87 87
 				$count++;
88 88
 			}
89 89
 		}
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 			->where($query->expr()->like(
105 105
 				'calendardata',
106 106
 				$query->createNamedParameter(
107
-					'%' . $this->db->escapeLikeParameter($pattern) . '%',
107
+					'%'.$this->db->escapeLikeParameter($pattern).'%',
108 108
 					IQueryBuilder::PARAM_STR
109 109
 				),
110 110
 				IQueryBuilder::PARAM_STR
Please login to merge, or discard this patch.
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -35,112 +35,112 @@
 block discarded – undo
35 35
 
36 36
 class CalDAVRemoveEmptyValue implements IRepairStep {
37 37
 
38
-	/** @var IDBConnection */
39
-	private $db;
40
-
41
-	/** @var CalDavBackend */
42
-	private $calDavBackend;
43
-
44
-	private LoggerInterface $logger;
45
-
46
-	public function __construct(IDBConnection $db, CalDavBackend $calDavBackend, LoggerInterface $logger) {
47
-		$this->db = $db;
48
-		$this->calDavBackend = $calDavBackend;
49
-		$this->logger = $logger;
50
-	}
51
-
52
-	public function getName() {
53
-		return 'Fix broken values of calendar objects';
54
-	}
55
-
56
-	public function run(IOutput $output) {
57
-		$pattern = ';VALUE=:';
58
-		$count = $warnings = 0;
59
-
60
-		$objects = $this->getInvalidObjects($pattern);
61
-
62
-		$output->startProgress(count($objects));
63
-		foreach ($objects as $row) {
64
-			$calObject = $this->calDavBackend->getCalendarObject((int)$row['calendarid'], $row['uri']);
65
-			$data = preg_replace('/' . $pattern . '/', ':', $calObject['calendardata']);
66
-
67
-			if ($data !== $calObject['calendardata']) {
68
-				$output->advance();
69
-
70
-				try {
71
-					$this->calDavBackend->getDenormalizedData($data);
72
-				} catch (InvalidDataException $e) {
73
-					$this->logger->info('Calendar object for calendar {cal} with uri {uri} still invalid', [
74
-						'app' => 'dav',
75
-						'cal' => (int)$row['calendarid'],
76
-						'uri' => $row['uri'],
77
-					]);
78
-					$warnings++;
79
-					continue;
80
-				}
81
-
82
-				$this->calDavBackend->updateCalendarObject((int)$row['calendarid'], $row['uri'], $data);
83
-				$count++;
84
-			}
85
-		}
86
-		$output->finishProgress();
87
-
88
-		if ($warnings > 0) {
89
-			$output->warning(sprintf('%d events could not be updated, see log file for more information', $warnings));
90
-		}
91
-		if ($count > 0) {
92
-			$output->info(sprintf('Updated %d events', $count));
93
-		}
94
-	}
95
-
96
-	protected function getInvalidObjects($pattern) {
97
-		if ($this->db->getDatabasePlatform() instanceof OraclePlatform) {
98
-			$rows = [];
99
-			$chunkSize = 500;
100
-			$query = $this->db->getQueryBuilder();
101
-			$query->select($query->func()->count('*', 'num_entries'))
102
-				->from('calendarobjects');
103
-			$result = $query->execute();
104
-			$count = $result->fetchOne();
105
-			$result->closeCursor();
106
-
107
-			$numChunks = ceil($count / $chunkSize);
108
-
109
-			$query = $this->db->getQueryBuilder();
110
-			$query->select(['calendarid', 'uri', 'calendardata'])
111
-				->from('calendarobjects')
112
-				->setMaxResults($chunkSize);
113
-			for ($chunk = 0; $chunk < $numChunks; $chunk++) {
114
-				$query->setFirstResult($chunk * $chunkSize);
115
-				$result = $query->execute();
116
-
117
-				while ($row = $result->fetch()) {
118
-					if (mb_strpos($row['calendardata'], $pattern) !== false) {
119
-						unset($row['calendardata']);
120
-						$rows[] = $row;
121
-					}
122
-				}
123
-				$result->closeCursor();
124
-			}
125
-			return $rows;
126
-		}
127
-
128
-		$query = $this->db->getQueryBuilder();
129
-		$query->select(['calendarid', 'uri'])
130
-			->from('calendarobjects')
131
-			->where($query->expr()->like(
132
-				'calendardata',
133
-				$query->createNamedParameter(
134
-					'%' . $this->db->escapeLikeParameter($pattern) . '%',
135
-					IQueryBuilder::PARAM_STR
136
-				),
137
-				IQueryBuilder::PARAM_STR
138
-			));
139
-
140
-		$result = $query->execute();
141
-		$rows = $result->fetchAll();
142
-		$result->closeCursor();
143
-
144
-		return $rows;
145
-	}
38
+    /** @var IDBConnection */
39
+    private $db;
40
+
41
+    /** @var CalDavBackend */
42
+    private $calDavBackend;
43
+
44
+    private LoggerInterface $logger;
45
+
46
+    public function __construct(IDBConnection $db, CalDavBackend $calDavBackend, LoggerInterface $logger) {
47
+        $this->db = $db;
48
+        $this->calDavBackend = $calDavBackend;
49
+        $this->logger = $logger;
50
+    }
51
+
52
+    public function getName() {
53
+        return 'Fix broken values of calendar objects';
54
+    }
55
+
56
+    public function run(IOutput $output) {
57
+        $pattern = ';VALUE=:';
58
+        $count = $warnings = 0;
59
+
60
+        $objects = $this->getInvalidObjects($pattern);
61
+
62
+        $output->startProgress(count($objects));
63
+        foreach ($objects as $row) {
64
+            $calObject = $this->calDavBackend->getCalendarObject((int)$row['calendarid'], $row['uri']);
65
+            $data = preg_replace('/' . $pattern . '/', ':', $calObject['calendardata']);
66
+
67
+            if ($data !== $calObject['calendardata']) {
68
+                $output->advance();
69
+
70
+                try {
71
+                    $this->calDavBackend->getDenormalizedData($data);
72
+                } catch (InvalidDataException $e) {
73
+                    $this->logger->info('Calendar object for calendar {cal} with uri {uri} still invalid', [
74
+                        'app' => 'dav',
75
+                        'cal' => (int)$row['calendarid'],
76
+                        'uri' => $row['uri'],
77
+                    ]);
78
+                    $warnings++;
79
+                    continue;
80
+                }
81
+
82
+                $this->calDavBackend->updateCalendarObject((int)$row['calendarid'], $row['uri'], $data);
83
+                $count++;
84
+            }
85
+        }
86
+        $output->finishProgress();
87
+
88
+        if ($warnings > 0) {
89
+            $output->warning(sprintf('%d events could not be updated, see log file for more information', $warnings));
90
+        }
91
+        if ($count > 0) {
92
+            $output->info(sprintf('Updated %d events', $count));
93
+        }
94
+    }
95
+
96
+    protected function getInvalidObjects($pattern) {
97
+        if ($this->db->getDatabasePlatform() instanceof OraclePlatform) {
98
+            $rows = [];
99
+            $chunkSize = 500;
100
+            $query = $this->db->getQueryBuilder();
101
+            $query->select($query->func()->count('*', 'num_entries'))
102
+                ->from('calendarobjects');
103
+            $result = $query->execute();
104
+            $count = $result->fetchOne();
105
+            $result->closeCursor();
106
+
107
+            $numChunks = ceil($count / $chunkSize);
108
+
109
+            $query = $this->db->getQueryBuilder();
110
+            $query->select(['calendarid', 'uri', 'calendardata'])
111
+                ->from('calendarobjects')
112
+                ->setMaxResults($chunkSize);
113
+            for ($chunk = 0; $chunk < $numChunks; $chunk++) {
114
+                $query->setFirstResult($chunk * $chunkSize);
115
+                $result = $query->execute();
116
+
117
+                while ($row = $result->fetch()) {
118
+                    if (mb_strpos($row['calendardata'], $pattern) !== false) {
119
+                        unset($row['calendardata']);
120
+                        $rows[] = $row;
121
+                    }
122
+                }
123
+                $result->closeCursor();
124
+            }
125
+            return $rows;
126
+        }
127
+
128
+        $query = $this->db->getQueryBuilder();
129
+        $query->select(['calendarid', 'uri'])
130
+            ->from('calendarobjects')
131
+            ->where($query->expr()->like(
132
+                'calendardata',
133
+                $query->createNamedParameter(
134
+                    '%' . $this->db->escapeLikeParameter($pattern) . '%',
135
+                    IQueryBuilder::PARAM_STR
136
+                ),
137
+                IQueryBuilder::PARAM_STR
138
+            ));
139
+
140
+        $result = $query->execute();
141
+        $rows = $result->fetchAll();
142
+        $result->closeCursor();
143
+
144
+        return $rows;
145
+    }
146 146
 }
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/Search/Xml/Filter/CompFilter.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
 		$reader->parseInnerTree();
40 40
 
41 41
 		if (!is_string($componentName)) {
42
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}comp-filter requires a valid name attribute');
42
+			throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}comp-filter requires a valid name attribute');
43 43
 		}
44 44
 
45 45
 		return $componentName;
Please login to merge, or discard this patch.
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -27,21 +27,21 @@
 block discarded – undo
27 27
 
28 28
 class CompFilter implements XmlDeserializable {
29 29
 
30
-	/**
31
-	 * @param Reader $reader
32
-	 * @throws BadRequest
33
-	 * @return string
34
-	 */
35
-	public static function xmlDeserialize(Reader $reader) {
36
-		$att = $reader->parseAttributes();
37
-		$componentName = $att['name'];
30
+    /**
31
+     * @param Reader $reader
32
+     * @throws BadRequest
33
+     * @return string
34
+     */
35
+    public static function xmlDeserialize(Reader $reader) {
36
+        $att = $reader->parseAttributes();
37
+        $componentName = $att['name'];
38 38
 
39
-		$reader->parseInnerTree();
39
+        $reader->parseInnerTree();
40 40
 
41
-		if (!is_string($componentName)) {
42
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}comp-filter requires a valid name attribute');
43
-		}
41
+        if (!is_string($componentName)) {
42
+            throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}comp-filter requires a valid name attribute');
43
+        }
44 44
 
45
-		return $componentName;
46
-	}
45
+        return $componentName;
46
+    }
47 47
 }
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/Search/Xml/Filter/PropFilter.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
 		$reader->parseInnerTree();
40 40
 
41 41
 		if (!is_string($componentName)) {
42
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}prop-filter requires a valid name attribute');
42
+			throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}prop-filter requires a valid name attribute');
43 43
 		}
44 44
 
45 45
 		return $componentName;
Please login to merge, or discard this patch.
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -27,21 +27,21 @@
 block discarded – undo
27 27
 
28 28
 class PropFilter implements XmlDeserializable {
29 29
 
30
-	/**
31
-	 * @param Reader $reader
32
-	 * @throws BadRequest
33
-	 * @return string
34
-	 */
35
-	public static function xmlDeserialize(Reader $reader) {
36
-		$att = $reader->parseAttributes();
37
-		$componentName = $att['name'];
30
+    /**
31
+     * @param Reader $reader
32
+     * @throws BadRequest
33
+     * @return string
34
+     */
35
+    public static function xmlDeserialize(Reader $reader) {
36
+        $att = $reader->parseAttributes();
37
+        $componentName = $att['name'];
38 38
 
39
-		$reader->parseInnerTree();
39
+        $reader->parseInnerTree();
40 40
 
41
-		if (!is_string($componentName)) {
42
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}prop-filter requires a valid name attribute');
43
-		}
41
+        if (!is_string($componentName)) {
42
+            throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}prop-filter requires a valid name attribute');
43
+        }
44 44
 
45
-		return $componentName;
46
-	}
45
+        return $componentName;
46
+    }
47 47
 }
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/Search/Xml/Filter/ParamFilter.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,11 +40,11 @@
 block discarded – undo
40 40
 		$reader->parseInnerTree();
41 41
 
42 42
 		if (!is_string($property)) {
43
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid property attribute');
43
+			throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}param-filter requires a valid property attribute');
44 44
 
45 45
 		}
46 46
 		if (!is_string($parameter)) {
47
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid parameter attribute');
47
+			throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}param-filter requires a valid parameter attribute');
48 48
 		}
49 49
 
50 50
 		return [
Please login to merge, or discard this patch.
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -27,28 +27,28 @@
 block discarded – undo
27 27
 
28 28
 class ParamFilter implements XmlDeserializable {
29 29
 
30
-	/**
31
-	 * @param Reader $reader
32
-	 * @throws BadRequest
33
-	 * @return string
34
-	 */
35
-	public static function xmlDeserialize(Reader $reader) {
36
-		$att = $reader->parseAttributes();
37
-		$property = $att['property'];
38
-		$parameter = $att['name'];
30
+    /**
31
+     * @param Reader $reader
32
+     * @throws BadRequest
33
+     * @return string
34
+     */
35
+    public static function xmlDeserialize(Reader $reader) {
36
+        $att = $reader->parseAttributes();
37
+        $property = $att['property'];
38
+        $parameter = $att['name'];
39 39
 
40
-		$reader->parseInnerTree();
40
+        $reader->parseInnerTree();
41 41
 
42
-		if (!is_string($property)) {
43
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid property attribute');
44
-		}
45
-		if (!is_string($parameter)) {
46
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid parameter attribute');
47
-		}
42
+        if (!is_string($property)) {
43
+            throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid property attribute');
44
+        }
45
+        if (!is_string($parameter)) {
46
+            throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid parameter attribute');
47
+        }
48 48
 
49
-		return [
50
-			'property' => $property,
51
-			'parameter' => $parameter,
52
-		];
53
-	}
49
+        return [
50
+            'property' => $property,
51
+            'parameter' => $parameter,
52
+        ];
53
+    }
54 54
 }
Please login to merge, or discard this patch.
lib/private/Repair/CleanTags.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -171,14 +171,14 @@
 block discarded – undo
171 171
 	protected function deleteOrphanEntries(IOutput $output, $repairInfo, $deleteTable, $deleteId, $sourceTable, $sourceId, $sourceNullColumn) {
172 172
 		$qb = $this->connection->getQueryBuilder();
173 173
 
174
-		$qb->select('d.' . $deleteId)
174
+		$qb->select('d.'.$deleteId)
175 175
 			->from($deleteTable, 'd')
176
-			->leftJoin('d', $sourceTable, 's', $qb->expr()->eq('d.' . $deleteId, 's.' . $sourceId))
176
+			->leftJoin('d', $sourceTable, 's', $qb->expr()->eq('d.'.$deleteId, 's.'.$sourceId))
177 177
 			->where(
178 178
 				$qb->expr()->eq('d.type', $qb->expr()->literal('files'))
179 179
 			)
180 180
 			->andWhere(
181
-				$qb->expr()->isNull('s.' . $sourceNullColumn)
181
+				$qb->expr()->isNull('s.'.$sourceNullColumn)
182 182
 			);
183 183
 		$result = $qb->execute();
184 184
 
Please login to merge, or discard this patch.
Indentation   +167 added lines, -167 removed lines patch added patch discarded remove patch
@@ -38,171 +38,171 @@
 block discarded – undo
38 38
  * @package OC\Repair
39 39
  */
40 40
 class CleanTags implements IRepairStep {
41
-	/** @var IDBConnection */
42
-	protected $connection;
43
-
44
-	/** @var IUserManager */
45
-	protected $userManager;
46
-
47
-	protected $deletedTags = 0;
48
-
49
-	/**
50
-	 * @param IDBConnection $connection
51
-	 * @param IUserManager $userManager
52
-	 */
53
-	public function __construct(IDBConnection $connection, IUserManager $userManager) {
54
-		$this->connection = $connection;
55
-		$this->userManager = $userManager;
56
-	}
57
-
58
-	/**
59
-	 * @return string
60
-	 */
61
-	public function getName() {
62
-		return 'Clean tags and favorites';
63
-	}
64
-
65
-	/**
66
-	 * Updates the configuration after running an update
67
-	 */
68
-	public function run(IOutput $output) {
69
-		$this->deleteOrphanTags($output);
70
-		$this->deleteOrphanFileEntries($output);
71
-		$this->deleteOrphanTagEntries($output);
72
-		$this->deleteOrphanCategoryEntries($output);
73
-	}
74
-
75
-	/**
76
-	 * Delete tags for deleted users
77
-	 */
78
-	protected function deleteOrphanTags(IOutput $output) {
79
-		$offset = 0;
80
-		while ($this->checkTags($offset)) {
81
-			$offset += 50;
82
-		}
83
-
84
-		$output->info(sprintf('%d tags of deleted users have been removed.', $this->deletedTags));
85
-	}
86
-
87
-	protected function checkTags($offset) {
88
-		$query = $this->connection->getQueryBuilder();
89
-		$query->select('uid')
90
-			->from('vcategory')
91
-			->groupBy('uid')
92
-			->orderBy('uid')
93
-			->setMaxResults(50)
94
-			->setFirstResult($offset);
95
-		$result = $query->execute();
96
-
97
-		$users = [];
98
-		$hadResults = false;
99
-		while ($row = $result->fetch()) {
100
-			$hadResults = true;
101
-			if (!$this->userManager->userExists($row['uid'])) {
102
-				$users[] = $row['uid'];
103
-			}
104
-		}
105
-		$result->closeCursor();
106
-
107
-		if (!$hadResults) {
108
-			// No more tags, stop looping
109
-			return false;
110
-		}
111
-
112
-		if (!empty($users)) {
113
-			$query = $this->connection->getQueryBuilder();
114
-			$query->delete('vcategory')
115
-				->where($query->expr()->in('uid', $query->createNamedParameter($users, IQueryBuilder::PARAM_STR_ARRAY)));
116
-			$this->deletedTags += $query->execute();
117
-		}
118
-		return true;
119
-	}
120
-
121
-	/**
122
-	 * Delete tag entries for deleted files
123
-	 */
124
-	protected function deleteOrphanFileEntries(IOutput $output) {
125
-		$this->deleteOrphanEntries(
126
-			$output,
127
-			'%d tags for delete files have been removed.',
128
-			'vcategory_to_object', 'objid',
129
-			'filecache', 'fileid', 'path_hash'
130
-		);
131
-	}
132
-
133
-	/**
134
-	 * Delete tag entries for deleted tags
135
-	 */
136
-	protected function deleteOrphanTagEntries(IOutput $output) {
137
-		$this->deleteOrphanEntries(
138
-			$output,
139
-			'%d tag entries for deleted tags have been removed.',
140
-			'vcategory_to_object', 'categoryid',
141
-			'vcategory', 'id', 'uid'
142
-		);
143
-	}
144
-
145
-	/**
146
-	 * Delete tags that have no entries
147
-	 */
148
-	protected function deleteOrphanCategoryEntries(IOutput $output) {
149
-		$this->deleteOrphanEntries(
150
-			$output,
151
-			'%d tags with no entries have been removed.',
152
-			'vcategory', 'id',
153
-			'vcategory_to_object', 'categoryid', 'type'
154
-		);
155
-	}
156
-
157
-	/**
158
-	 * Deletes all entries from $deleteTable that do not have a matching entry in $sourceTable
159
-	 *
160
-	 * A query joins $deleteTable.$deleteId = $sourceTable.$sourceId and checks
161
-	 * whether $sourceNullColumn is null. If it is null, the entry in $deleteTable
162
-	 * is being deleted.
163
-	 *
164
-	 * @param string $repairInfo
165
-	 * @param string $deleteTable
166
-	 * @param string $deleteId
167
-	 * @param string $sourceTable
168
-	 * @param string $sourceId
169
-	 * @param string $sourceNullColumn	If this column is null in the source table,
170
-	 * 								the entry is deleted in the $deleteTable
171
-	 */
172
-	protected function deleteOrphanEntries(IOutput $output, $repairInfo, $deleteTable, $deleteId, $sourceTable, $sourceId, $sourceNullColumn) {
173
-		$qb = $this->connection->getQueryBuilder();
174
-
175
-		$qb->select('d.' . $deleteId)
176
-			->from($deleteTable, 'd')
177
-			->leftJoin('d', $sourceTable, 's', $qb->expr()->eq('d.' . $deleteId, 's.' . $sourceId))
178
-			->where(
179
-				$qb->expr()->eq('d.type', $qb->expr()->literal('files'))
180
-			)
181
-			->andWhere(
182
-				$qb->expr()->isNull('s.' . $sourceNullColumn)
183
-			);
184
-		$result = $qb->execute();
185
-
186
-		$orphanItems = [];
187
-		while ($row = $result->fetch()) {
188
-			$orphanItems[] = (int) $row[$deleteId];
189
-		}
190
-
191
-		if (!empty($orphanItems)) {
192
-			$orphanItemsBatch = array_chunk($orphanItems, 200);
193
-			foreach ($orphanItemsBatch as $items) {
194
-				$qb->delete($deleteTable)
195
-					->where(
196
-						$qb->expr()->eq('type', $qb->expr()->literal('files'))
197
-					)
198
-					->andWhere($qb->expr()->in($deleteId, $qb->createParameter('ids')));
199
-				$qb->setParameter('ids', $items, IQueryBuilder::PARAM_INT_ARRAY);
200
-				$qb->execute();
201
-			}
202
-		}
203
-
204
-		if ($repairInfo) {
205
-			$output->info(sprintf($repairInfo, count($orphanItems)));
206
-		}
207
-	}
41
+    /** @var IDBConnection */
42
+    protected $connection;
43
+
44
+    /** @var IUserManager */
45
+    protected $userManager;
46
+
47
+    protected $deletedTags = 0;
48
+
49
+    /**
50
+     * @param IDBConnection $connection
51
+     * @param IUserManager $userManager
52
+     */
53
+    public function __construct(IDBConnection $connection, IUserManager $userManager) {
54
+        $this->connection = $connection;
55
+        $this->userManager = $userManager;
56
+    }
57
+
58
+    /**
59
+     * @return string
60
+     */
61
+    public function getName() {
62
+        return 'Clean tags and favorites';
63
+    }
64
+
65
+    /**
66
+     * Updates the configuration after running an update
67
+     */
68
+    public function run(IOutput $output) {
69
+        $this->deleteOrphanTags($output);
70
+        $this->deleteOrphanFileEntries($output);
71
+        $this->deleteOrphanTagEntries($output);
72
+        $this->deleteOrphanCategoryEntries($output);
73
+    }
74
+
75
+    /**
76
+     * Delete tags for deleted users
77
+     */
78
+    protected function deleteOrphanTags(IOutput $output) {
79
+        $offset = 0;
80
+        while ($this->checkTags($offset)) {
81
+            $offset += 50;
82
+        }
83
+
84
+        $output->info(sprintf('%d tags of deleted users have been removed.', $this->deletedTags));
85
+    }
86
+
87
+    protected function checkTags($offset) {
88
+        $query = $this->connection->getQueryBuilder();
89
+        $query->select('uid')
90
+            ->from('vcategory')
91
+            ->groupBy('uid')
92
+            ->orderBy('uid')
93
+            ->setMaxResults(50)
94
+            ->setFirstResult($offset);
95
+        $result = $query->execute();
96
+
97
+        $users = [];
98
+        $hadResults = false;
99
+        while ($row = $result->fetch()) {
100
+            $hadResults = true;
101
+            if (!$this->userManager->userExists($row['uid'])) {
102
+                $users[] = $row['uid'];
103
+            }
104
+        }
105
+        $result->closeCursor();
106
+
107
+        if (!$hadResults) {
108
+            // No more tags, stop looping
109
+            return false;
110
+        }
111
+
112
+        if (!empty($users)) {
113
+            $query = $this->connection->getQueryBuilder();
114
+            $query->delete('vcategory')
115
+                ->where($query->expr()->in('uid', $query->createNamedParameter($users, IQueryBuilder::PARAM_STR_ARRAY)));
116
+            $this->deletedTags += $query->execute();
117
+        }
118
+        return true;
119
+    }
120
+
121
+    /**
122
+     * Delete tag entries for deleted files
123
+     */
124
+    protected function deleteOrphanFileEntries(IOutput $output) {
125
+        $this->deleteOrphanEntries(
126
+            $output,
127
+            '%d tags for delete files have been removed.',
128
+            'vcategory_to_object', 'objid',
129
+            'filecache', 'fileid', 'path_hash'
130
+        );
131
+    }
132
+
133
+    /**
134
+     * Delete tag entries for deleted tags
135
+     */
136
+    protected function deleteOrphanTagEntries(IOutput $output) {
137
+        $this->deleteOrphanEntries(
138
+            $output,
139
+            '%d tag entries for deleted tags have been removed.',
140
+            'vcategory_to_object', 'categoryid',
141
+            'vcategory', 'id', 'uid'
142
+        );
143
+    }
144
+
145
+    /**
146
+     * Delete tags that have no entries
147
+     */
148
+    protected function deleteOrphanCategoryEntries(IOutput $output) {
149
+        $this->deleteOrphanEntries(
150
+            $output,
151
+            '%d tags with no entries have been removed.',
152
+            'vcategory', 'id',
153
+            'vcategory_to_object', 'categoryid', 'type'
154
+        );
155
+    }
156
+
157
+    /**
158
+     * Deletes all entries from $deleteTable that do not have a matching entry in $sourceTable
159
+     *
160
+     * A query joins $deleteTable.$deleteId = $sourceTable.$sourceId and checks
161
+     * whether $sourceNullColumn is null. If it is null, the entry in $deleteTable
162
+     * is being deleted.
163
+     *
164
+     * @param string $repairInfo
165
+     * @param string $deleteTable
166
+     * @param string $deleteId
167
+     * @param string $sourceTable
168
+     * @param string $sourceId
169
+     * @param string $sourceNullColumn	If this column is null in the source table,
170
+     * 								the entry is deleted in the $deleteTable
171
+     */
172
+    protected function deleteOrphanEntries(IOutput $output, $repairInfo, $deleteTable, $deleteId, $sourceTable, $sourceId, $sourceNullColumn) {
173
+        $qb = $this->connection->getQueryBuilder();
174
+
175
+        $qb->select('d.' . $deleteId)
176
+            ->from($deleteTable, 'd')
177
+            ->leftJoin('d', $sourceTable, 's', $qb->expr()->eq('d.' . $deleteId, 's.' . $sourceId))
178
+            ->where(
179
+                $qb->expr()->eq('d.type', $qb->expr()->literal('files'))
180
+            )
181
+            ->andWhere(
182
+                $qb->expr()->isNull('s.' . $sourceNullColumn)
183
+            );
184
+        $result = $qb->execute();
185
+
186
+        $orphanItems = [];
187
+        while ($row = $result->fetch()) {
188
+            $orphanItems[] = (int) $row[$deleteId];
189
+        }
190
+
191
+        if (!empty($orphanItems)) {
192
+            $orphanItemsBatch = array_chunk($orphanItems, 200);
193
+            foreach ($orphanItemsBatch as $items) {
194
+                $qb->delete($deleteTable)
195
+                    ->where(
196
+                        $qb->expr()->eq('type', $qb->expr()->literal('files'))
197
+                    )
198
+                    ->andWhere($qb->expr()->in($deleteId, $qb->createParameter('ids')));
199
+                $qb->setParameter('ids', $items, IQueryBuilder::PARAM_INT_ARRAY);
200
+                $qb->execute();
201
+            }
202
+        }
203
+
204
+        if ($repairInfo) {
205
+            $output->info(sprintf($repairInfo, count($orphanItems)));
206
+        }
207
+    }
208 208
 }
Please login to merge, or discard this patch.