Passed
Push — master ( 1b5db2...2445b9 )
by Morris
14:45 queued 11s
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
@@ -33,89 +33,89 @@
 block discarded – undo
33 33
  * Repairs shares with invalid data
34 34
  */
35 35
 class RepairInvalidShares implements IRepairStep {
36
-	public const CHUNK_SIZE = 200;
37
-
38
-	/** @var \OCP\IConfig */
39
-	protected $config;
40
-
41
-	/** @var \OCP\IDBConnection */
42
-	protected $connection;
43
-
44
-	/**
45
-	 * @param \OCP\IConfig $config
46
-	 * @param \OCP\IDBConnection $connection
47
-	 */
48
-	public function __construct($config, $connection) {
49
-		$this->connection = $connection;
50
-		$this->config = $config;
51
-	}
52
-
53
-	public function getName() {
54
-		return 'Repair invalid shares';
55
-	}
56
-
57
-	/**
58
-	 * Adjust file share permissions
59
-	 */
60
-	private function adjustFileSharePermissions(IOutput $out) {
61
-		$mask = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE;
62
-		$builder = $this->connection->getQueryBuilder();
63
-
64
-		$permsFunc = $builder->expr()->bitwiseAnd('permissions', $mask);
65
-		$builder
66
-			->update('share')
67
-			->set('permissions', $permsFunc)
68
-			->where($builder->expr()->eq('item_type', $builder->expr()->literal('file')))
69
-			->andWhere($builder->expr()->neq('permissions', $permsFunc));
70
-
71
-		$updatedEntries = $builder->execute();
72
-		if ($updatedEntries > 0) {
73
-			$out->info('Fixed file share permissions for ' . $updatedEntries . ' shares');
74
-		}
75
-	}
76
-
77
-	/**
78
-	 * Remove shares where the parent share does not exist anymore
79
-	 */
80
-	private function removeSharesNonExistingParent(IOutput $out) {
81
-		$deletedEntries = 0;
82
-
83
-		$query = $this->connection->getQueryBuilder();
84
-		$query->select('s1.parent')
85
-			->from('share', 's1')
86
-			->where($query->expr()->isNotNull('s1.parent'))
87
-				->andWhere($query->expr()->isNull('s2.id'))
88
-			->leftJoin('s1', 'share', 's2', $query->expr()->eq('s1.parent', 's2.id'))
89
-			->groupBy('s1.parent')
90
-			->setMaxResults(self::CHUNK_SIZE);
91
-
92
-		$deleteQuery = $this->connection->getQueryBuilder();
93
-		$deleteQuery->delete('share')
94
-			->where($deleteQuery->expr()->eq('parent', $deleteQuery->createParameter('parent')));
95
-
96
-		$deletedInLastChunk = self::CHUNK_SIZE;
97
-		while ($deletedInLastChunk === self::CHUNK_SIZE) {
98
-			$deletedInLastChunk = 0;
99
-			$result = $query->execute();
100
-			while ($row = $result->fetch()) {
101
-				$deletedInLastChunk++;
102
-				$deletedEntries += $deleteQuery->setParameter('parent', (int) $row['parent'])
103
-					->execute();
104
-			}
105
-			$result->closeCursor();
106
-		}
107
-
108
-		if ($deletedEntries) {
109
-			$out->info('Removed ' . $deletedEntries . ' shares where the parent did not exist');
110
-		}
111
-	}
112
-
113
-	public function run(IOutput $out) {
114
-		$ocVersionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0');
115
-		if (version_compare($ocVersionFromBeforeUpdate, '12.0.0.11', '<')) {
116
-			$this->adjustFileSharePermissions($out);
117
-		}
118
-
119
-		$this->removeSharesNonExistingParent($out);
120
-	}
36
+    public const CHUNK_SIZE = 200;
37
+
38
+    /** @var \OCP\IConfig */
39
+    protected $config;
40
+
41
+    /** @var \OCP\IDBConnection */
42
+    protected $connection;
43
+
44
+    /**
45
+     * @param \OCP\IConfig $config
46
+     * @param \OCP\IDBConnection $connection
47
+     */
48
+    public function __construct($config, $connection) {
49
+        $this->connection = $connection;
50
+        $this->config = $config;
51
+    }
52
+
53
+    public function getName() {
54
+        return 'Repair invalid shares';
55
+    }
56
+
57
+    /**
58
+     * Adjust file share permissions
59
+     */
60
+    private function adjustFileSharePermissions(IOutput $out) {
61
+        $mask = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE;
62
+        $builder = $this->connection->getQueryBuilder();
63
+
64
+        $permsFunc = $builder->expr()->bitwiseAnd('permissions', $mask);
65
+        $builder
66
+            ->update('share')
67
+            ->set('permissions', $permsFunc)
68
+            ->where($builder->expr()->eq('item_type', $builder->expr()->literal('file')))
69
+            ->andWhere($builder->expr()->neq('permissions', $permsFunc));
70
+
71
+        $updatedEntries = $builder->execute();
72
+        if ($updatedEntries > 0) {
73
+            $out->info('Fixed file share permissions for ' . $updatedEntries . ' shares');
74
+        }
75
+    }
76
+
77
+    /**
78
+     * Remove shares where the parent share does not exist anymore
79
+     */
80
+    private function removeSharesNonExistingParent(IOutput $out) {
81
+        $deletedEntries = 0;
82
+
83
+        $query = $this->connection->getQueryBuilder();
84
+        $query->select('s1.parent')
85
+            ->from('share', 's1')
86
+            ->where($query->expr()->isNotNull('s1.parent'))
87
+                ->andWhere($query->expr()->isNull('s2.id'))
88
+            ->leftJoin('s1', 'share', 's2', $query->expr()->eq('s1.parent', 's2.id'))
89
+            ->groupBy('s1.parent')
90
+            ->setMaxResults(self::CHUNK_SIZE);
91
+
92
+        $deleteQuery = $this->connection->getQueryBuilder();
93
+        $deleteQuery->delete('share')
94
+            ->where($deleteQuery->expr()->eq('parent', $deleteQuery->createParameter('parent')));
95
+
96
+        $deletedInLastChunk = self::CHUNK_SIZE;
97
+        while ($deletedInLastChunk === self::CHUNK_SIZE) {
98
+            $deletedInLastChunk = 0;
99
+            $result = $query->execute();
100
+            while ($row = $result->fetch()) {
101
+                $deletedInLastChunk++;
102
+                $deletedEntries += $deleteQuery->setParameter('parent', (int) $row['parent'])
103
+                    ->execute();
104
+            }
105
+            $result->closeCursor();
106
+        }
107
+
108
+        if ($deletedEntries) {
109
+            $out->info('Removed ' . $deletedEntries . ' shares where the parent did not exist');
110
+        }
111
+    }
112
+
113
+    public function run(IOutput $out) {
114
+        $ocVersionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0');
115
+        if (version_compare($ocVersionFromBeforeUpdate, '12.0.0.11', '<')) {
116
+            $this->adjustFileSharePermissions($out);
117
+        }
118
+
119
+        $this->removeSharesNonExistingParent($out);
120
+    }
121 121
 }
Please login to merge, or discard this patch.
apps/federatedfilesharing/appinfo/routes.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -23,18 +23,18 @@
 block discarded – undo
23 23
  */
24 24
 
25 25
 return [
26
-	'routes' => [
27
-		['name' => 'MountPublicLink#createFederatedShare', 'url' => '/createFederatedShare', 'verb' => 'POST'],
28
-		['name' => 'MountPublicLink#askForFederatedShare', 'url' => '/askForFederatedShare', 'verb' => 'POST'],
29
-	],
30
-	'ocs' => [
31
-		['root' => '/cloud', 'name' => 'RequestHandler#createShare', 'url' => '/shares', 'verb' => 'POST'],
32
-		['root' => '/cloud', 'name' => 'RequestHandler#reShare', 'url' => '/shares/{id}/reshare', 'verb' => 'POST'],
33
-		['root' => '/cloud', 'name' => 'RequestHandler#updatePermissions', 'url' => '/shares/{id}/permissions', 'verb' => 'POST'],
34
-		['root' => '/cloud', 'name' => 'RequestHandler#acceptShare', 'url' => '/shares/{id}/accept', 'verb' => 'POST'],
35
-		['root' => '/cloud', 'name' => 'RequestHandler#declineShare', 'url' => '/shares/{id}/decline', 'verb' => 'POST'],
36
-		['root' => '/cloud', 'name' => 'RequestHandler#unshare', 'url' => '/shares/{id}/unshare', 'verb' => 'POST'],
37
-		['root' => '/cloud', 'name' => 'RequestHandler#revoke', 'url' => '/shares/{id}/revoke', 'verb' => 'POST'],
38
-		['root' => '/cloud', 'name' => 'RequestHandler#move', 'url' => '/shares/{id}/move', 'verb' => 'POST'],
39
-	],
26
+    'routes' => [
27
+        ['name' => 'MountPublicLink#createFederatedShare', 'url' => '/createFederatedShare', 'verb' => 'POST'],
28
+        ['name' => 'MountPublicLink#askForFederatedShare', 'url' => '/askForFederatedShare', 'verb' => 'POST'],
29
+    ],
30
+    'ocs' => [
31
+        ['root' => '/cloud', 'name' => 'RequestHandler#createShare', 'url' => '/shares', 'verb' => 'POST'],
32
+        ['root' => '/cloud', 'name' => 'RequestHandler#reShare', 'url' => '/shares/{id}/reshare', 'verb' => 'POST'],
33
+        ['root' => '/cloud', 'name' => 'RequestHandler#updatePermissions', 'url' => '/shares/{id}/permissions', 'verb' => 'POST'],
34
+        ['root' => '/cloud', 'name' => 'RequestHandler#acceptShare', 'url' => '/shares/{id}/accept', 'verb' => 'POST'],
35
+        ['root' => '/cloud', 'name' => 'RequestHandler#declineShare', 'url' => '/shares/{id}/decline', 'verb' => 'POST'],
36
+        ['root' => '/cloud', 'name' => 'RequestHandler#unshare', 'url' => '/shares/{id}/unshare', 'verb' => 'POST'],
37
+        ['root' => '/cloud', 'name' => 'RequestHandler#revoke', 'url' => '/shares/{id}/revoke', 'verb' => 'POST'],
38
+        ['root' => '/cloud', 'name' => 'RequestHandler#move', 'url' => '/shares/{id}/move', 'verb' => 'POST'],
39
+    ],
40 40
 ];
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   +296 added lines, -296 removed lines patch added patch discarded remove patch
@@ -53,309 +53,309 @@
 block discarded – undo
53 53
  */
54 54
 class ProviderFactory implements IProviderFactory {
55 55
 
56
-	/** @var IServerContainer */
57
-	private $serverContainer;
58
-	/** @var DefaultShareProvider */
59
-	private $defaultProvider = null;
60
-	/** @var FederatedShareProvider */
61
-	private $federatedProvider = null;
62
-	/** @var  ShareByMailProvider */
63
-	private $shareByMailProvider;
64
-	/** @var  \OCA\Circles\ShareByCircleProvider */
65
-	private $shareByCircleProvider = null;
66
-	/** @var bool */
67
-	private $circlesAreNotAvailable = false;
68
-	/** @var \OCA\Talk\Share\RoomShareProvider */
69
-	private $roomShareProvider = null;
70
-
71
-	private $registeredShareProviders = [];
72
-
73
-	private $shareProviders = [];
74
-
75
-	/**
76
-	 * IProviderFactory constructor.
77
-	 *
78
-	 * @param IServerContainer $serverContainer
79
-	 */
80
-	public function __construct(IServerContainer $serverContainer) {
81
-		$this->serverContainer = $serverContainer;
82
-	}
83
-
84
-	public function registerProvider(string $shareProviderClass): void {
85
-		$this->registeredShareProviders[] = $shareProviderClass;
86
-	}
87
-
88
-	/**
89
-	 * Create the default share provider.
90
-	 *
91
-	 * @return DefaultShareProvider
92
-	 */
93
-	protected function defaultShareProvider() {
94
-		if ($this->defaultProvider === null) {
95
-			$this->defaultProvider = new DefaultShareProvider(
96
-				$this->serverContainer->getDatabaseConnection(),
97
-				$this->serverContainer->getUserManager(),
98
-				$this->serverContainer->getGroupManager(),
99
-				$this->serverContainer->getLazyRootFolder(),
100
-				$this->serverContainer->getMailer(),
101
-				$this->serverContainer->query(Defaults::class),
102
-				$this->serverContainer->getL10NFactory(),
103
-				$this->serverContainer->getURLGenerator(),
104
-				$this->serverContainer->getConfig()
105
-			);
106
-		}
107
-
108
-		return $this->defaultProvider;
109
-	}
110
-
111
-	/**
112
-	 * Create the federated share provider
113
-	 *
114
-	 * @return FederatedShareProvider
115
-	 */
116
-	protected function federatedShareProvider() {
117
-		if ($this->federatedProvider === null) {
118
-			/*
56
+    /** @var IServerContainer */
57
+    private $serverContainer;
58
+    /** @var DefaultShareProvider */
59
+    private $defaultProvider = null;
60
+    /** @var FederatedShareProvider */
61
+    private $federatedProvider = null;
62
+    /** @var  ShareByMailProvider */
63
+    private $shareByMailProvider;
64
+    /** @var  \OCA\Circles\ShareByCircleProvider */
65
+    private $shareByCircleProvider = null;
66
+    /** @var bool */
67
+    private $circlesAreNotAvailable = false;
68
+    /** @var \OCA\Talk\Share\RoomShareProvider */
69
+    private $roomShareProvider = null;
70
+
71
+    private $registeredShareProviders = [];
72
+
73
+    private $shareProviders = [];
74
+
75
+    /**
76
+     * IProviderFactory constructor.
77
+     *
78
+     * @param IServerContainer $serverContainer
79
+     */
80
+    public function __construct(IServerContainer $serverContainer) {
81
+        $this->serverContainer = $serverContainer;
82
+    }
83
+
84
+    public function registerProvider(string $shareProviderClass): void {
85
+        $this->registeredShareProviders[] = $shareProviderClass;
86
+    }
87
+
88
+    /**
89
+     * Create the default share provider.
90
+     *
91
+     * @return DefaultShareProvider
92
+     */
93
+    protected function defaultShareProvider() {
94
+        if ($this->defaultProvider === null) {
95
+            $this->defaultProvider = new DefaultShareProvider(
96
+                $this->serverContainer->getDatabaseConnection(),
97
+                $this->serverContainer->getUserManager(),
98
+                $this->serverContainer->getGroupManager(),
99
+                $this->serverContainer->getLazyRootFolder(),
100
+                $this->serverContainer->getMailer(),
101
+                $this->serverContainer->query(Defaults::class),
102
+                $this->serverContainer->getL10NFactory(),
103
+                $this->serverContainer->getURLGenerator(),
104
+                $this->serverContainer->getConfig()
105
+            );
106
+        }
107
+
108
+        return $this->defaultProvider;
109
+    }
110
+
111
+    /**
112
+     * Create the federated share provider
113
+     *
114
+     * @return FederatedShareProvider
115
+     */
116
+    protected function federatedShareProvider() {
117
+        if ($this->federatedProvider === null) {
118
+            /*
119 119
 			 * Check if the app is enabled
120 120
 			 */
121
-			$appManager = $this->serverContainer->getAppManager();
122
-			if (!$appManager->isEnabledForUser('federatedfilesharing')) {
123
-				return null;
124
-			}
121
+            $appManager = $this->serverContainer->getAppManager();
122
+            if (!$appManager->isEnabledForUser('federatedfilesharing')) {
123
+                return null;
124
+            }
125 125
 
126
-			/*
126
+            /*
127 127
 			 * TODO: add factory to federated sharing app
128 128
 			 */
129
-			$l = $this->serverContainer->getL10N('federatedfilesharing');
130
-			$addressHandler = new AddressHandler(
131
-				$this->serverContainer->getURLGenerator(),
132
-				$l,
133
-				$this->serverContainer->getCloudIdManager()
134
-			);
135
-			$notifications = new Notifications(
136
-				$addressHandler,
137
-				$this->serverContainer->getHTTPClientService(),
138
-				$this->serverContainer->query(\OCP\OCS\IDiscoveryService::class),
139
-				$this->serverContainer->getJobList(),
140
-				\OC::$server->getCloudFederationProviderManager(),
141
-				\OC::$server->getCloudFederationFactory(),
142
-				$this->serverContainer->query(IEventDispatcher::class)
143
-			);
144
-			$tokenHandler = new TokenHandler(
145
-				$this->serverContainer->getSecureRandom()
146
-			);
147
-
148
-			$this->federatedProvider = new FederatedShareProvider(
149
-				$this->serverContainer->getDatabaseConnection(),
150
-				$addressHandler,
151
-				$notifications,
152
-				$tokenHandler,
153
-				$l,
154
-				$this->serverContainer->getLogger(),
155
-				$this->serverContainer->getLazyRootFolder(),
156
-				$this->serverContainer->getConfig(),
157
-				$this->serverContainer->getUserManager(),
158
-				$this->serverContainer->getCloudIdManager(),
159
-				$this->serverContainer->getGlobalScaleConfig(),
160
-				$this->serverContainer->getCloudFederationProviderManager()
161
-			);
162
-		}
163
-
164
-		return $this->federatedProvider;
165
-	}
166
-
167
-	/**
168
-	 * Create the federated share provider
169
-	 *
170
-	 * @return ShareByMailProvider
171
-	 */
172
-	protected function getShareByMailProvider() {
173
-		if ($this->shareByMailProvider === null) {
174
-			/*
129
+            $l = $this->serverContainer->getL10N('federatedfilesharing');
130
+            $addressHandler = new AddressHandler(
131
+                $this->serverContainer->getURLGenerator(),
132
+                $l,
133
+                $this->serverContainer->getCloudIdManager()
134
+            );
135
+            $notifications = new Notifications(
136
+                $addressHandler,
137
+                $this->serverContainer->getHTTPClientService(),
138
+                $this->serverContainer->query(\OCP\OCS\IDiscoveryService::class),
139
+                $this->serverContainer->getJobList(),
140
+                \OC::$server->getCloudFederationProviderManager(),
141
+                \OC::$server->getCloudFederationFactory(),
142
+                $this->serverContainer->query(IEventDispatcher::class)
143
+            );
144
+            $tokenHandler = new TokenHandler(
145
+                $this->serverContainer->getSecureRandom()
146
+            );
147
+
148
+            $this->federatedProvider = new FederatedShareProvider(
149
+                $this->serverContainer->getDatabaseConnection(),
150
+                $addressHandler,
151
+                $notifications,
152
+                $tokenHandler,
153
+                $l,
154
+                $this->serverContainer->getLogger(),
155
+                $this->serverContainer->getLazyRootFolder(),
156
+                $this->serverContainer->getConfig(),
157
+                $this->serverContainer->getUserManager(),
158
+                $this->serverContainer->getCloudIdManager(),
159
+                $this->serverContainer->getGlobalScaleConfig(),
160
+                $this->serverContainer->getCloudFederationProviderManager()
161
+            );
162
+        }
163
+
164
+        return $this->federatedProvider;
165
+    }
166
+
167
+    /**
168
+     * Create the federated share provider
169
+     *
170
+     * @return ShareByMailProvider
171
+     */
172
+    protected function getShareByMailProvider() {
173
+        if ($this->shareByMailProvider === null) {
174
+            /*
175 175
 			 * Check if the app is enabled
176 176
 			 */
177
-			$appManager = $this->serverContainer->getAppManager();
178
-			if (!$appManager->isEnabledForUser('sharebymail')) {
179
-				return null;
180
-			}
181
-
182
-			$settingsManager = new SettingsManager($this->serverContainer->getConfig());
183
-
184
-			$this->shareByMailProvider = new ShareByMailProvider(
185
-				$this->serverContainer->getDatabaseConnection(),
186
-				$this->serverContainer->getSecureRandom(),
187
-				$this->serverContainer->getUserManager(),
188
-				$this->serverContainer->getLazyRootFolder(),
189
-				$this->serverContainer->getL10N('sharebymail'),
190
-				$this->serverContainer->getLogger(),
191
-				$this->serverContainer->getMailer(),
192
-				$this->serverContainer->getURLGenerator(),
193
-				$this->serverContainer->getActivityManager(),
194
-				$settingsManager,
195
-				$this->serverContainer->query(Defaults::class),
196
-				$this->serverContainer->getHasher(),
197
-				$this->serverContainer->get(IEventDispatcher::class)
198
-			);
199
-		}
200
-
201
-		return $this->shareByMailProvider;
202
-	}
203
-
204
-
205
-	/**
206
-	 * Create the circle share provider
207
-	 *
208
-	 * @return FederatedShareProvider
209
-	 *
210
-	 * @suppress PhanUndeclaredClassMethod
211
-	 */
212
-	protected function getShareByCircleProvider() {
213
-		if ($this->circlesAreNotAvailable) {
214
-			return null;
215
-		}
216
-
217
-		if (!$this->serverContainer->getAppManager()->isEnabledForUser('circles') ||
218
-			!class_exists('\OCA\Circles\ShareByCircleProvider')
219
-		) {
220
-			$this->circlesAreNotAvailable = true;
221
-			return null;
222
-		}
223
-
224
-		if ($this->shareByCircleProvider === null) {
225
-			$this->shareByCircleProvider = new \OCA\Circles\ShareByCircleProvider(
226
-				$this->serverContainer->getDatabaseConnection(),
227
-				$this->serverContainer->getSecureRandom(),
228
-				$this->serverContainer->getUserManager(),
229
-				$this->serverContainer->getLazyRootFolder(),
230
-				$this->serverContainer->getL10N('circles'),
231
-				$this->serverContainer->getLogger(),
232
-				$this->serverContainer->getURLGenerator()
233
-			);
234
-		}
235
-
236
-		return $this->shareByCircleProvider;
237
-	}
238
-
239
-	/**
240
-	 * Create the room share provider
241
-	 *
242
-	 * @return RoomShareProvider
243
-	 */
244
-	protected function getRoomShareProvider() {
245
-		if ($this->roomShareProvider === null) {
246
-			/*
177
+            $appManager = $this->serverContainer->getAppManager();
178
+            if (!$appManager->isEnabledForUser('sharebymail')) {
179
+                return null;
180
+            }
181
+
182
+            $settingsManager = new SettingsManager($this->serverContainer->getConfig());
183
+
184
+            $this->shareByMailProvider = new ShareByMailProvider(
185
+                $this->serverContainer->getDatabaseConnection(),
186
+                $this->serverContainer->getSecureRandom(),
187
+                $this->serverContainer->getUserManager(),
188
+                $this->serverContainer->getLazyRootFolder(),
189
+                $this->serverContainer->getL10N('sharebymail'),
190
+                $this->serverContainer->getLogger(),
191
+                $this->serverContainer->getMailer(),
192
+                $this->serverContainer->getURLGenerator(),
193
+                $this->serverContainer->getActivityManager(),
194
+                $settingsManager,
195
+                $this->serverContainer->query(Defaults::class),
196
+                $this->serverContainer->getHasher(),
197
+                $this->serverContainer->get(IEventDispatcher::class)
198
+            );
199
+        }
200
+
201
+        return $this->shareByMailProvider;
202
+    }
203
+
204
+
205
+    /**
206
+     * Create the circle share provider
207
+     *
208
+     * @return FederatedShareProvider
209
+     *
210
+     * @suppress PhanUndeclaredClassMethod
211
+     */
212
+    protected function getShareByCircleProvider() {
213
+        if ($this->circlesAreNotAvailable) {
214
+            return null;
215
+        }
216
+
217
+        if (!$this->serverContainer->getAppManager()->isEnabledForUser('circles') ||
218
+            !class_exists('\OCA\Circles\ShareByCircleProvider')
219
+        ) {
220
+            $this->circlesAreNotAvailable = true;
221
+            return null;
222
+        }
223
+
224
+        if ($this->shareByCircleProvider === null) {
225
+            $this->shareByCircleProvider = new \OCA\Circles\ShareByCircleProvider(
226
+                $this->serverContainer->getDatabaseConnection(),
227
+                $this->serverContainer->getSecureRandom(),
228
+                $this->serverContainer->getUserManager(),
229
+                $this->serverContainer->getLazyRootFolder(),
230
+                $this->serverContainer->getL10N('circles'),
231
+                $this->serverContainer->getLogger(),
232
+                $this->serverContainer->getURLGenerator()
233
+            );
234
+        }
235
+
236
+        return $this->shareByCircleProvider;
237
+    }
238
+
239
+    /**
240
+     * Create the room share provider
241
+     *
242
+     * @return RoomShareProvider
243
+     */
244
+    protected function getRoomShareProvider() {
245
+        if ($this->roomShareProvider === null) {
246
+            /*
247 247
 			 * Check if the app is enabled
248 248
 			 */
249
-			$appManager = $this->serverContainer->getAppManager();
250
-			if (!$appManager->isEnabledForUser('spreed')) {
251
-				return null;
252
-			}
253
-
254
-			try {
255
-				$this->roomShareProvider = $this->serverContainer->query('\OCA\Talk\Share\RoomShareProvider');
256
-			} catch (\OCP\AppFramework\QueryException $e) {
257
-				return null;
258
-			}
259
-		}
260
-
261
-		return $this->roomShareProvider;
262
-	}
263
-
264
-	/**
265
-	 * @inheritdoc
266
-	 */
267
-	public function getProvider($id) {
268
-		$provider = null;
269
-		if (isset($this->shareProviders[$id])) {
270
-			return $this->shareProviders[$id];
271
-		}
272
-
273
-		if ($id === 'ocinternal') {
274
-			$provider = $this->defaultShareProvider();
275
-		} elseif ($id === 'ocFederatedSharing') {
276
-			$provider = $this->federatedShareProvider();
277
-		} elseif ($id === 'ocMailShare') {
278
-			$provider = $this->getShareByMailProvider();
279
-		} elseif ($id === 'ocCircleShare') {
280
-			$provider = $this->getShareByCircleProvider();
281
-		} elseif ($id === 'ocRoomShare') {
282
-			$provider = $this->getRoomShareProvider();
283
-		}
284
-
285
-		foreach ($this->registeredShareProviders as $shareProvider) {
286
-			/** @var IShareProvider $instance */
287
-			$instance = $this->serverContainer->get($shareProvider);
288
-			$this->shareProviders[$instance->identifier()] = $instance;
289
-		}
290
-
291
-		if (isset($this->shareProviders[$id])) {
292
-			$provider = $this->shareProviders[$id];
293
-		}
294
-
295
-		if ($provider === null) {
296
-			throw new ProviderException('No provider with id .' . $id . ' found.');
297
-		}
298
-
299
-		return $provider;
300
-	}
301
-
302
-	/**
303
-	 * @inheritdoc
304
-	 */
305
-	public function getProviderForType($shareType) {
306
-		$provider = null;
307
-
308
-		if ($shareType === IShare::TYPE_USER ||
309
-			$shareType === IShare::TYPE_GROUP ||
310
-			$shareType === IShare::TYPE_LINK
311
-		) {
312
-			$provider = $this->defaultShareProvider();
313
-		} elseif ($shareType === IShare::TYPE_REMOTE || $shareType === IShare::TYPE_REMOTE_GROUP) {
314
-			$provider = $this->federatedShareProvider();
315
-		} elseif ($shareType === IShare::TYPE_EMAIL) {
316
-			$provider = $this->getShareByMailProvider();
317
-		} elseif ($shareType === IShare::TYPE_CIRCLE) {
318
-			$provider = $this->getShareByCircleProvider();
319
-		} elseif ($shareType === IShare::TYPE_ROOM) {
320
-			$provider = $this->getRoomShareProvider();
321
-		} elseif ($shareType === IShare::TYPE_DECK) {
322
-			$provider = $this->getProvider('deck');
323
-		}
324
-
325
-
326
-		if ($provider === null) {
327
-			throw new ProviderException('No share provider for share type ' . $shareType);
328
-		}
329
-
330
-		return $provider;
331
-	}
332
-
333
-	public function getAllProviders() {
334
-		$shares = [$this->defaultShareProvider(), $this->federatedShareProvider()];
335
-		$shareByMail = $this->getShareByMailProvider();
336
-		if ($shareByMail !== null) {
337
-			$shares[] = $shareByMail;
338
-		}
339
-		$shareByCircle = $this->getShareByCircleProvider();
340
-		if ($shareByCircle !== null) {
341
-			$shares[] = $shareByCircle;
342
-		}
343
-		$roomShare = $this->getRoomShareProvider();
344
-		if ($roomShare !== null) {
345
-			$shares[] = $roomShare;
346
-		}
347
-
348
-		foreach ($this->registeredShareProviders as $shareProvider) {
349
-			/** @var IShareProvider $instance */
350
-			$instance = $this->serverContainer->get($shareProvider);
351
-			if (!isset($this->shareProviders[$instance->identifier()])) {
352
-				$this->shareProviders[$instance->identifier()] = $instance;
353
-			}
354
-			$shares[] = $this->shareProviders[$instance->identifier()];
355
-		}
356
-
357
-
358
-
359
-		return $shares;
360
-	}
249
+            $appManager = $this->serverContainer->getAppManager();
250
+            if (!$appManager->isEnabledForUser('spreed')) {
251
+                return null;
252
+            }
253
+
254
+            try {
255
+                $this->roomShareProvider = $this->serverContainer->query('\OCA\Talk\Share\RoomShareProvider');
256
+            } catch (\OCP\AppFramework\QueryException $e) {
257
+                return null;
258
+            }
259
+        }
260
+
261
+        return $this->roomShareProvider;
262
+    }
263
+
264
+    /**
265
+     * @inheritdoc
266
+     */
267
+    public function getProvider($id) {
268
+        $provider = null;
269
+        if (isset($this->shareProviders[$id])) {
270
+            return $this->shareProviders[$id];
271
+        }
272
+
273
+        if ($id === 'ocinternal') {
274
+            $provider = $this->defaultShareProvider();
275
+        } elseif ($id === 'ocFederatedSharing') {
276
+            $provider = $this->federatedShareProvider();
277
+        } elseif ($id === 'ocMailShare') {
278
+            $provider = $this->getShareByMailProvider();
279
+        } elseif ($id === 'ocCircleShare') {
280
+            $provider = $this->getShareByCircleProvider();
281
+        } elseif ($id === 'ocRoomShare') {
282
+            $provider = $this->getRoomShareProvider();
283
+        }
284
+
285
+        foreach ($this->registeredShareProviders as $shareProvider) {
286
+            /** @var IShareProvider $instance */
287
+            $instance = $this->serverContainer->get($shareProvider);
288
+            $this->shareProviders[$instance->identifier()] = $instance;
289
+        }
290
+
291
+        if (isset($this->shareProviders[$id])) {
292
+            $provider = $this->shareProviders[$id];
293
+        }
294
+
295
+        if ($provider === null) {
296
+            throw new ProviderException('No provider with id .' . $id . ' found.');
297
+        }
298
+
299
+        return $provider;
300
+    }
301
+
302
+    /**
303
+     * @inheritdoc
304
+     */
305
+    public function getProviderForType($shareType) {
306
+        $provider = null;
307
+
308
+        if ($shareType === IShare::TYPE_USER ||
309
+            $shareType === IShare::TYPE_GROUP ||
310
+            $shareType === IShare::TYPE_LINK
311
+        ) {
312
+            $provider = $this->defaultShareProvider();
313
+        } elseif ($shareType === IShare::TYPE_REMOTE || $shareType === IShare::TYPE_REMOTE_GROUP) {
314
+            $provider = $this->federatedShareProvider();
315
+        } elseif ($shareType === IShare::TYPE_EMAIL) {
316
+            $provider = $this->getShareByMailProvider();
317
+        } elseif ($shareType === IShare::TYPE_CIRCLE) {
318
+            $provider = $this->getShareByCircleProvider();
319
+        } elseif ($shareType === IShare::TYPE_ROOM) {
320
+            $provider = $this->getRoomShareProvider();
321
+        } elseif ($shareType === IShare::TYPE_DECK) {
322
+            $provider = $this->getProvider('deck');
323
+        }
324
+
325
+
326
+        if ($provider === null) {
327
+            throw new ProviderException('No share provider for share type ' . $shareType);
328
+        }
329
+
330
+        return $provider;
331
+    }
332
+
333
+    public function getAllProviders() {
334
+        $shares = [$this->defaultShareProvider(), $this->federatedShareProvider()];
335
+        $shareByMail = $this->getShareByMailProvider();
336
+        if ($shareByMail !== null) {
337
+            $shares[] = $shareByMail;
338
+        }
339
+        $shareByCircle = $this->getShareByCircleProvider();
340
+        if ($shareByCircle !== null) {
341
+            $shares[] = $shareByCircle;
342
+        }
343
+        $roomShare = $this->getRoomShareProvider();
344
+        if ($roomShare !== null) {
345
+            $shares[] = $roomShare;
346
+        }
347
+
348
+        foreach ($this->registeredShareProviders as $shareProvider) {
349
+            /** @var IShareProvider $instance */
350
+            $instance = $this->serverContainer->get($shareProvider);
351
+            if (!isset($this->shareProviders[$instance->identifier()])) {
352
+                $this->shareProviders[$instance->identifier()] = $instance;
353
+            }
354
+            $shares[] = $this->shareProviders[$instance->identifier()];
355
+        }
356
+
357
+
358
+
359
+        return $shares;
360
+    }
361 361
 }
Please login to merge, or discard this patch.
lib/private/Migration/ConsoleOutput.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -37,57 +37,57 @@
 block discarded – undo
37 37
  */
38 38
 class ConsoleOutput implements IOutput {
39 39
 
40
-	/** @var OutputInterface */
41
-	private $output;
40
+    /** @var OutputInterface */
41
+    private $output;
42 42
 
43
-	/** @var ProgressBar */
44
-	private $progressBar;
43
+    /** @var ProgressBar */
44
+    private $progressBar;
45 45
 
46
-	public function __construct(OutputInterface $output) {
47
-		$this->output = $output;
48
-	}
46
+    public function __construct(OutputInterface $output) {
47
+        $this->output = $output;
48
+    }
49 49
 
50
-	/**
51
-	 * @param string $message
52
-	 */
53
-	public function info($message) {
54
-		$this->output->writeln("<info>$message</info>");
55
-	}
50
+    /**
51
+     * @param string $message
52
+     */
53
+    public function info($message) {
54
+        $this->output->writeln("<info>$message</info>");
55
+    }
56 56
 
57
-	/**
58
-	 * @param string $message
59
-	 */
60
-	public function warning($message) {
61
-		$this->output->writeln("<comment>$message</comment>");
62
-	}
57
+    /**
58
+     * @param string $message
59
+     */
60
+    public function warning($message) {
61
+        $this->output->writeln("<comment>$message</comment>");
62
+    }
63 63
 
64
-	/**
65
-	 * @param int $max
66
-	 */
67
-	public function startProgress($max = 0) {
68
-		if (!is_null($this->progressBar)) {
69
-			$this->progressBar->finish();
70
-		}
71
-		$this->progressBar = new ProgressBar($this->output);
72
-		$this->progressBar->start($max);
73
-	}
64
+    /**
65
+     * @param int $max
66
+     */
67
+    public function startProgress($max = 0) {
68
+        if (!is_null($this->progressBar)) {
69
+            $this->progressBar->finish();
70
+        }
71
+        $this->progressBar = new ProgressBar($this->output);
72
+        $this->progressBar->start($max);
73
+    }
74 74
 
75
-	/**
76
-	 * @param int $step
77
-	 * @param string $description
78
-	 */
79
-	public function advance($step = 1, $description = '') {
80
-		if (!is_null($this->progressBar)) {
81
-			$this->progressBar = new ProgressBar($this->output);
82
-			$this->progressBar->start();
83
-		}
84
-		$this->progressBar->advance($step);
85
-	}
75
+    /**
76
+     * @param int $step
77
+     * @param string $description
78
+     */
79
+    public function advance($step = 1, $description = '') {
80
+        if (!is_null($this->progressBar)) {
81
+            $this->progressBar = new ProgressBar($this->output);
82
+            $this->progressBar->start();
83
+        }
84
+        $this->progressBar->advance($step);
85
+    }
86 86
 
87
-	public function finishProgress() {
88
-		if (is_null($this->progressBar)) {
89
-			return;
90
-		}
91
-		$this->progressBar->finish();
92
-	}
87
+    public function finishProgress() {
88
+        if (is_null($this->progressBar)) {
89
+            return;
90
+        }
91
+        $this->progressBar->finish();
92
+    }
93 93
 }
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   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -35,118 +35,118 @@
 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
-	/** @var ILogger */
45
-	private $logger;
46
-
47
-	/**
48
-	 * @param IDBConnection $db
49
-	 * @param CalDavBackend $calDavBackend
50
-	 * @param ILogger $logger
51
-	 */
52
-	public function __construct(IDBConnection $db, CalDavBackend $calDavBackend, ILogger $logger) {
53
-		$this->db = $db;
54
-		$this->calDavBackend = $calDavBackend;
55
-		$this->logger = $logger;
56
-	}
57
-
58
-	public function getName() {
59
-		return 'Fix broken values of calendar objects';
60
-	}
61
-
62
-	public function run(IOutput $output) {
63
-		$pattern = ';VALUE=:';
64
-		$count = $warnings = 0;
65
-
66
-		$objects = $this->getInvalidObjects($pattern);
67
-
68
-		$output->startProgress(count($objects));
69
-		foreach ($objects as $row) {
70
-			$calObject = $this->calDavBackend->getCalendarObject((int)$row['calendarid'], $row['uri']);
71
-			$data = preg_replace('/' . $pattern . '/', ':', $calObject['calendardata']);
72
-
73
-			if ($data !== $calObject['calendardata']) {
74
-				$output->advance();
75
-
76
-				try {
77
-					$this->calDavBackend->getDenormalizedData($data);
78
-				} catch (InvalidDataException $e) {
79
-					$this->logger->info('Calendar object for calendar {cal} with uri {uri} still invalid', [
80
-						'app' => 'dav',
81
-						'cal' => (int)$row['calendarid'],
82
-						'uri' => $row['uri'],
83
-					]);
84
-					$warnings++;
85
-					continue;
86
-				}
87
-
88
-				$this->calDavBackend->updateCalendarObject((int)$row['calendarid'], $row['uri'], $data);
89
-				$count++;
90
-			}
91
-		}
92
-		$output->finishProgress();
93
-
94
-		if ($warnings > 0) {
95
-			$output->warning(sprintf('%d events could not be updated, see log file for more information', $warnings));
96
-		}
97
-		if ($count > 0) {
98
-			$output->info(sprintf('Updated %d events', $count));
99
-		}
100
-	}
101
-
102
-	protected function getInvalidObjects($pattern) {
103
-		if ($this->db->getDatabasePlatform() instanceof OraclePlatform) {
104
-			$rows = [];
105
-			$chunkSize = 500;
106
-			$query = $this->db->getQueryBuilder();
107
-			$query->select($query->func()->count('*', 'num_entries'))
108
-				->from('calendarobjects');
109
-			$result = $query->execute();
110
-			$count = $result->fetchOne();
111
-			$result->closeCursor();
112
-
113
-			$numChunks = ceil($count / $chunkSize);
114
-
115
-			$query = $this->db->getQueryBuilder();
116
-			$query->select(['calendarid', 'uri', 'calendardata'])
117
-				->from('calendarobjects')
118
-				->setMaxResults($chunkSize);
119
-			for ($chunk = 0; $chunk < $numChunks; $chunk++) {
120
-				$query->setFirstResult($chunk * $chunkSize);
121
-				$result = $query->execute();
122
-
123
-				while ($row = $result->fetch()) {
124
-					if (mb_strpos($row['calendardata'], $pattern) !== false) {
125
-						unset($row['calendardata']);
126
-						$rows[] = $row;
127
-					}
128
-				}
129
-				$result->closeCursor();
130
-			}
131
-			return $rows;
132
-		}
133
-
134
-		$query = $this->db->getQueryBuilder();
135
-		$query->select(['calendarid', 'uri'])
136
-			->from('calendarobjects')
137
-			->where($query->expr()->like(
138
-				'calendardata',
139
-				$query->createNamedParameter(
140
-					'%' . $this->db->escapeLikeParameter($pattern) . '%',
141
-					IQueryBuilder::PARAM_STR
142
-				),
143
-				IQueryBuilder::PARAM_STR
144
-			));
145
-
146
-		$result = $query->execute();
147
-		$rows = $result->fetchAll();
148
-		$result->closeCursor();
149
-
150
-		return $rows;
151
-	}
38
+    /** @var IDBConnection */
39
+    private $db;
40
+
41
+    /** @var CalDavBackend */
42
+    private $calDavBackend;
43
+
44
+    /** @var ILogger */
45
+    private $logger;
46
+
47
+    /**
48
+     * @param IDBConnection $db
49
+     * @param CalDavBackend $calDavBackend
50
+     * @param ILogger $logger
51
+     */
52
+    public function __construct(IDBConnection $db, CalDavBackend $calDavBackend, ILogger $logger) {
53
+        $this->db = $db;
54
+        $this->calDavBackend = $calDavBackend;
55
+        $this->logger = $logger;
56
+    }
57
+
58
+    public function getName() {
59
+        return 'Fix broken values of calendar objects';
60
+    }
61
+
62
+    public function run(IOutput $output) {
63
+        $pattern = ';VALUE=:';
64
+        $count = $warnings = 0;
65
+
66
+        $objects = $this->getInvalidObjects($pattern);
67
+
68
+        $output->startProgress(count($objects));
69
+        foreach ($objects as $row) {
70
+            $calObject = $this->calDavBackend->getCalendarObject((int)$row['calendarid'], $row['uri']);
71
+            $data = preg_replace('/' . $pattern . '/', ':', $calObject['calendardata']);
72
+
73
+            if ($data !== $calObject['calendardata']) {
74
+                $output->advance();
75
+
76
+                try {
77
+                    $this->calDavBackend->getDenormalizedData($data);
78
+                } catch (InvalidDataException $e) {
79
+                    $this->logger->info('Calendar object for calendar {cal} with uri {uri} still invalid', [
80
+                        'app' => 'dav',
81
+                        'cal' => (int)$row['calendarid'],
82
+                        'uri' => $row['uri'],
83
+                    ]);
84
+                    $warnings++;
85
+                    continue;
86
+                }
87
+
88
+                $this->calDavBackend->updateCalendarObject((int)$row['calendarid'], $row['uri'], $data);
89
+                $count++;
90
+            }
91
+        }
92
+        $output->finishProgress();
93
+
94
+        if ($warnings > 0) {
95
+            $output->warning(sprintf('%d events could not be updated, see log file for more information', $warnings));
96
+        }
97
+        if ($count > 0) {
98
+            $output->info(sprintf('Updated %d events', $count));
99
+        }
100
+    }
101
+
102
+    protected function getInvalidObjects($pattern) {
103
+        if ($this->db->getDatabasePlatform() instanceof OraclePlatform) {
104
+            $rows = [];
105
+            $chunkSize = 500;
106
+            $query = $this->db->getQueryBuilder();
107
+            $query->select($query->func()->count('*', 'num_entries'))
108
+                ->from('calendarobjects');
109
+            $result = $query->execute();
110
+            $count = $result->fetchOne();
111
+            $result->closeCursor();
112
+
113
+            $numChunks = ceil($count / $chunkSize);
114
+
115
+            $query = $this->db->getQueryBuilder();
116
+            $query->select(['calendarid', 'uri', 'calendardata'])
117
+                ->from('calendarobjects')
118
+                ->setMaxResults($chunkSize);
119
+            for ($chunk = 0; $chunk < $numChunks; $chunk++) {
120
+                $query->setFirstResult($chunk * $chunkSize);
121
+                $result = $query->execute();
122
+
123
+                while ($row = $result->fetch()) {
124
+                    if (mb_strpos($row['calendardata'], $pattern) !== false) {
125
+                        unset($row['calendardata']);
126
+                        $rows[] = $row;
127
+                    }
128
+                }
129
+                $result->closeCursor();
130
+            }
131
+            return $rows;
132
+        }
133
+
134
+        $query = $this->db->getQueryBuilder();
135
+        $query->select(['calendarid', 'uri'])
136
+            ->from('calendarobjects')
137
+            ->where($query->expr()->like(
138
+                'calendardata',
139
+                $query->createNamedParameter(
140
+                    '%' . $this->db->escapeLikeParameter($pattern) . '%',
141
+                    IQueryBuilder::PARAM_STR
142
+                ),
143
+                IQueryBuilder::PARAM_STR
144
+            ));
145
+
146
+        $result = $query->execute();
147
+        $rows = $result->fetchAll();
148
+        $result->closeCursor();
149
+
150
+        return $rows;
151
+    }
152 152
 }
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.