1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc. |
4
|
|
|
* @copyright Copyright (c) 2016 Joas Schilling <[email protected]> |
5
|
|
|
* |
6
|
|
|
* @author Christoph Wurst <[email protected]> |
7
|
|
|
* @author Joas Schilling <[email protected]> |
8
|
|
|
* @author Julius Härtl <[email protected]> |
9
|
|
|
* @author Lukas Reschke <[email protected]> |
10
|
|
|
* @author Mario Danic <[email protected]> |
11
|
|
|
* @author Morris Jobke <[email protected]> |
12
|
|
|
* @author Robin Appelman <[email protected]> |
13
|
|
|
* @author Roeland Jago Douma <[email protected]> |
14
|
|
|
* @author Thomas Citharel <[email protected]> |
15
|
|
|
* @author Victor Dubiniuk <[email protected]> |
16
|
|
|
* |
17
|
|
|
* @license AGPL-3.0 |
18
|
|
|
* |
19
|
|
|
* This code is free software: you can redistribute it and/or modify |
20
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
21
|
|
|
* as published by the Free Software Foundation. |
22
|
|
|
* |
23
|
|
|
* This program is distributed in the hope that it will be useful, |
24
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
25
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
26
|
|
|
* GNU Affero General Public License for more details. |
27
|
|
|
* |
28
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
29
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
30
|
|
|
* |
31
|
|
|
*/ |
32
|
|
|
|
33
|
|
|
namespace OC\Core; |
34
|
|
|
|
35
|
|
|
use OC\Authentication\Events\RemoteWipeFinished; |
36
|
|
|
use OC\Authentication\Events\RemoteWipeStarted; |
37
|
|
|
use OC\Authentication\Listeners\RemoteWipeActivityListener; |
38
|
|
|
use OC\Authentication\Listeners\RemoteWipeEmailListener; |
39
|
|
|
use OC\Authentication\Listeners\RemoteWipeNotificationsListener; |
40
|
|
|
use OC\Authentication\Listeners\UserDeletedStoreCleanupListener; |
41
|
|
|
use OC\Authentication\Listeners\UserDeletedTokenCleanupListener; |
42
|
|
|
use OC\Authentication\Notifications\Notifier as AuthenticationNotifier; |
43
|
|
|
use OC\Core\Notification\CoreNotifier; |
44
|
|
|
use OC\DB\Connection; |
45
|
|
|
use OC\DB\MissingColumnInformation; |
46
|
|
|
use OC\DB\MissingIndexInformation; |
47
|
|
|
use OC\DB\MissingPrimaryKeyInformation; |
48
|
|
|
use OC\DB\SchemaWrapper; |
49
|
|
|
use OCP\AppFramework\App; |
50
|
|
|
use OCP\EventDispatcher\IEventDispatcher; |
51
|
|
|
use OCP\IDBConnection; |
52
|
|
|
use OCP\User\Events\UserDeletedEvent; |
53
|
|
|
use OCP\Util; |
54
|
|
|
use Symfony\Component\EventDispatcher\GenericEvent; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Class Application |
58
|
|
|
* |
59
|
|
|
* @package OC\Core |
60
|
|
|
*/ |
61
|
|
|
class Application extends App { |
62
|
|
|
public function __construct() { |
63
|
|
|
parent::__construct('core'); |
64
|
|
|
|
65
|
|
|
$container = $this->getContainer(); |
66
|
|
|
|
67
|
|
|
$container->registerService('defaultMailAddress', function () { |
68
|
|
|
return Util::getDefaultEmailAddress('lostpassword-noreply'); |
69
|
|
|
}); |
70
|
|
|
|
71
|
|
|
$server = $container->getServer(); |
72
|
|
|
/** @var IEventDispatcher $eventDispatcher */ |
73
|
|
|
$eventDispatcher = $server->query(IEventDispatcher::class); |
74
|
|
|
|
75
|
|
|
$notificationManager = $server->getNotificationManager(); |
76
|
|
|
$notificationManager->registerNotifierService(CoreNotifier::class); |
77
|
|
|
$notificationManager->registerNotifierService(AuthenticationNotifier::class); |
78
|
|
|
|
79
|
|
|
$oldEventDispatcher = $server->getEventDispatcher(); |
80
|
|
|
|
81
|
|
|
$oldEventDispatcher->addListener(IDBConnection::CHECK_MISSING_INDEXES_EVENT, |
|
|
|
|
82
|
|
|
function (GenericEvent $event) use ($container) { |
83
|
|
|
/** @var MissingIndexInformation $subject */ |
84
|
|
|
$subject = $event->getSubject(); |
85
|
|
|
|
86
|
|
|
$schema = new SchemaWrapper($container->query(Connection::class)); |
87
|
|
|
|
88
|
|
|
if ($schema->hasTable('share')) { |
89
|
|
|
$table = $schema->getTable('share'); |
90
|
|
|
|
91
|
|
|
if (!$table->hasIndex('share_with_index')) { |
92
|
|
|
$subject->addHintForMissingSubject($table->getName(), 'share_with_index'); |
93
|
|
|
} |
94
|
|
|
if (!$table->hasIndex('parent_index')) { |
95
|
|
|
$subject->addHintForMissingSubject($table->getName(), 'parent_index'); |
96
|
|
|
} |
97
|
|
|
if (!$table->hasIndex('owner_index')) { |
98
|
|
|
$subject->addHintForMissingSubject($table->getName(), 'owner_index'); |
99
|
|
|
} |
100
|
|
|
if (!$table->hasIndex('initiator_index')) { |
101
|
|
|
$subject->addHintForMissingSubject($table->getName(), 'initiator_index'); |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
if ($schema->hasTable('filecache')) { |
106
|
|
|
$table = $schema->getTable('filecache'); |
107
|
|
|
|
108
|
|
|
if (!$table->hasIndex('fs_mtime')) { |
109
|
|
|
$subject->addHintForMissingSubject($table->getName(), 'fs_mtime'); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
if (!$table->hasIndex('fs_size')) { |
113
|
|
|
$subject->addHintForMissingSubject($table->getName(), 'fs_size'); |
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
if ($schema->hasTable('twofactor_providers')) { |
118
|
|
|
$table = $schema->getTable('twofactor_providers'); |
119
|
|
|
|
120
|
|
|
if (!$table->hasIndex('twofactor_providers_uid')) { |
121
|
|
|
$subject->addHintForMissingSubject($table->getName(), 'twofactor_providers_uid'); |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
if ($schema->hasTable('login_flow_v2')) { |
126
|
|
|
$table = $schema->getTable('login_flow_v2'); |
127
|
|
|
|
128
|
|
|
if (!$table->hasIndex('poll_token')) { |
129
|
|
|
$subject->addHintForMissingSubject($table->getName(), 'poll_token'); |
130
|
|
|
} |
131
|
|
|
if (!$table->hasIndex('login_token')) { |
132
|
|
|
$subject->addHintForMissingSubject($table->getName(), 'login_token'); |
133
|
|
|
} |
134
|
|
|
if (!$table->hasIndex('timestamp')) { |
135
|
|
|
$subject->addHintForMissingSubject($table->getName(), 'timestamp'); |
136
|
|
|
} |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
if ($schema->hasTable('whats_new')) { |
140
|
|
|
$table = $schema->getTable('whats_new'); |
141
|
|
|
|
142
|
|
|
if (!$table->hasIndex('version')) { |
143
|
|
|
$subject->addHintForMissingSubject($table->getName(), 'version'); |
144
|
|
|
} |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
if ($schema->hasTable('cards')) { |
148
|
|
|
$table = $schema->getTable('cards'); |
149
|
|
|
|
150
|
|
|
if (!$table->hasIndex('cards_abid')) { |
151
|
|
|
$subject->addHintForMissingSubject($table->getName(), 'cards_abid'); |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
if (!$table->hasIndex('cards_abiduri')) { |
155
|
|
|
$subject->addHintForMissingSubject($table->getName(), 'cards_abiduri'); |
156
|
|
|
} |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
if ($schema->hasTable('cards_properties')) { |
160
|
|
|
$table = $schema->getTable('cards_properties'); |
161
|
|
|
|
162
|
|
|
if (!$table->hasIndex('cards_prop_abid')) { |
163
|
|
|
$subject->addHintForMissingSubject($table->getName(), 'cards_prop_abid'); |
164
|
|
|
} |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
if ($schema->hasTable('calendarobjects_props')) { |
168
|
|
|
$table = $schema->getTable('calendarobjects_props'); |
169
|
|
|
|
170
|
|
|
if (!$table->hasIndex('calendarobject_calid_index')) { |
171
|
|
|
$subject->addHintForMissingSubject($table->getName(), 'calendarobject_calid_index'); |
172
|
|
|
} |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
if ($schema->hasTable('schedulingobjects')) { |
176
|
|
|
$table = $schema->getTable('schedulingobjects'); |
177
|
|
|
if (!$table->hasIndex('schedulobj_principuri_index')) { |
178
|
|
|
$subject->addHintForMissingSubject($table->getName(), 'schedulobj_principuri_index'); |
179
|
|
|
} |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
if ($schema->hasTable('properties')) { |
183
|
|
|
$table = $schema->getTable('properties'); |
184
|
|
|
if (!$table->hasIndex('properties_path_index')) { |
185
|
|
|
$subject->addHintForMissingSubject($table->getName(), 'properties_path_index'); |
186
|
|
|
} |
187
|
|
|
} |
188
|
|
|
} |
189
|
|
|
); |
190
|
|
|
|
191
|
|
|
$oldEventDispatcher->addListener(IDBConnection::CHECK_MISSING_PRIMARY_KEYS_EVENT, |
|
|
|
|
192
|
|
|
function (GenericEvent $event) use ($container) { |
193
|
|
|
/** @var MissingPrimaryKeyInformation $subject */ |
194
|
|
|
$subject = $event->getSubject(); |
195
|
|
|
|
196
|
|
|
$schema = new SchemaWrapper($container->query(Connection::class)); |
197
|
|
|
|
198
|
|
|
if ($schema->hasTable('federated_reshares')) { |
199
|
|
|
$table = $schema->getTable('federated_reshares'); |
200
|
|
|
|
201
|
|
|
if (!$table->hasPrimaryKey()) { |
202
|
|
|
$subject->addHintForMissingSubject($table->getName()); |
203
|
|
|
} |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
if ($schema->hasTable('systemtag_object_mapping')) { |
207
|
|
|
$table = $schema->getTable('systemtag_object_mapping'); |
208
|
|
|
|
209
|
|
|
if (!$table->hasPrimaryKey()) { |
210
|
|
|
$subject->addHintForMissingSubject($table->getName()); |
211
|
|
|
} |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
if ($schema->hasTable('comments_read_markers')) { |
215
|
|
|
$table = $schema->getTable('comments_read_markers'); |
216
|
|
|
|
217
|
|
|
if (!$table->hasPrimaryKey()) { |
218
|
|
|
$subject->addHintForMissingSubject($table->getName()); |
219
|
|
|
} |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
if ($schema->hasTable('collres_resources')) { |
223
|
|
|
$table = $schema->getTable('collres_resources'); |
224
|
|
|
|
225
|
|
|
if (!$table->hasPrimaryKey()) { |
226
|
|
|
$subject->addHintForMissingSubject($table->getName()); |
227
|
|
|
} |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
if ($schema->hasTable('collres_accesscache')) { |
231
|
|
|
$table = $schema->getTable('collres_accesscache'); |
232
|
|
|
|
233
|
|
|
if (!$table->hasPrimaryKey()) { |
234
|
|
|
$subject->addHintForMissingSubject($table->getName()); |
235
|
|
|
} |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
if ($schema->hasTable('filecache_extended')) { |
239
|
|
|
$table = $schema->getTable('filecache_extended'); |
240
|
|
|
|
241
|
|
|
if (!$table->hasPrimaryKey()) { |
242
|
|
|
$subject->addHintForMissingSubject($table->getName()); |
243
|
|
|
} |
244
|
|
|
} |
245
|
|
|
} |
246
|
|
|
); |
247
|
|
|
|
248
|
|
|
$oldEventDispatcher->addListener(IDBConnection::CHECK_MISSING_COLUMNS_EVENT, |
|
|
|
|
249
|
|
|
function (GenericEvent $event) use ($container) { |
250
|
|
|
/** @var MissingColumnInformation $subject */ |
251
|
|
|
$subject = $event->getSubject(); |
252
|
|
|
|
253
|
|
|
$schema = new SchemaWrapper($container->query(Connection::class)); |
254
|
|
|
|
255
|
|
|
if ($schema->hasTable('comments')) { |
256
|
|
|
$table = $schema->getTable('comments'); |
257
|
|
|
|
258
|
|
|
if (!$table->hasColumn('reference_id')) { |
259
|
|
|
$subject->addHintForMissingColumn($table->getName(), 'reference_id'); |
260
|
|
|
} |
261
|
|
|
} |
262
|
|
|
} |
263
|
|
|
); |
264
|
|
|
|
265
|
|
|
$eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeActivityListener::class); |
266
|
|
|
$eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeNotificationsListener::class); |
267
|
|
|
$eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeEmailListener::class); |
268
|
|
|
$eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeActivityListener::class); |
269
|
|
|
$eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeNotificationsListener::class); |
270
|
|
|
$eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeEmailListener::class); |
271
|
|
|
$eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedStoreCleanupListener::class); |
272
|
|
|
$eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedTokenCleanupListener::class); |
273
|
|
|
} |
274
|
|
|
} |
275
|
|
|
|
This class constant has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.