| Conditions | 53 |
| Paths | 2 |
| Total Lines | 255 |
| Code Lines | 139 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 70 | public function __construct() { |
||
| 71 | parent::__construct('core'); |
||
| 72 | |||
| 73 | $container = $this->getContainer(); |
||
| 74 | |||
| 75 | $container->registerService('defaultMailAddress', function () { |
||
| 76 | return Util::getDefaultEmailAddress('lostpassword-noreply'); |
||
| 77 | }); |
||
| 78 | |||
| 79 | $server = $container->getServer(); |
||
| 80 | /** @var IEventDispatcher $eventDispatcher */ |
||
| 81 | $eventDispatcher = $server->query(IEventDispatcher::class); |
||
| 82 | |||
| 83 | $notificationManager = $server->getNotificationManager(); |
||
| 84 | $notificationManager->registerNotifierService(CoreNotifier::class); |
||
| 85 | $notificationManager->registerNotifierService(AuthenticationNotifier::class); |
||
| 86 | |||
| 87 | $oldEventDispatcher = $server->getEventDispatcher(); |
||
| 88 | |||
| 89 | $oldEventDispatcher->addListener(IDBConnection::CHECK_MISSING_INDEXES_EVENT, |
||
|
|
|||
| 90 | function (GenericEvent $event) use ($container) { |
||
| 91 | /** @var MissingIndexInformation $subject */ |
||
| 92 | $subject = $event->getSubject(); |
||
| 93 | |||
| 94 | $schema = new SchemaWrapper($container->query(Connection::class)); |
||
| 95 | |||
| 96 | if ($schema->hasTable('share')) { |
||
| 97 | $table = $schema->getTable('share'); |
||
| 98 | |||
| 99 | if (!$table->hasIndex('share_with_index')) { |
||
| 100 | $subject->addHintForMissingSubject($table->getName(), 'share_with_index'); |
||
| 101 | } |
||
| 102 | if (!$table->hasIndex('parent_index')) { |
||
| 103 | $subject->addHintForMissingSubject($table->getName(), 'parent_index'); |
||
| 104 | } |
||
| 105 | if (!$table->hasIndex('owner_index')) { |
||
| 106 | $subject->addHintForMissingSubject($table->getName(), 'owner_index'); |
||
| 107 | } |
||
| 108 | if (!$table->hasIndex('initiator_index')) { |
||
| 109 | $subject->addHintForMissingSubject($table->getName(), 'initiator_index'); |
||
| 110 | } |
||
| 111 | } |
||
| 112 | |||
| 113 | if ($schema->hasTable('filecache')) { |
||
| 114 | $table = $schema->getTable('filecache'); |
||
| 115 | |||
| 116 | if (!$table->hasIndex('fs_mtime')) { |
||
| 117 | $subject->addHintForMissingSubject($table->getName(), 'fs_mtime'); |
||
| 118 | } |
||
| 119 | |||
| 120 | if (!$table->hasIndex('fs_size')) { |
||
| 121 | $subject->addHintForMissingSubject($table->getName(), 'fs_size'); |
||
| 122 | } |
||
| 123 | |||
| 124 | if (!$table->hasIndex('fs_id_storage_size')) { |
||
| 125 | $subject->addHintForMissingSubject($table->getName(), 'fs_id_storage_size'); |
||
| 126 | } |
||
| 127 | |||
| 128 | if (!$table->hasIndex('fs_storage_path_prefix') && !$schema->getDatabasePlatform() instanceof PostgreSQL94Platform) { |
||
| 129 | $subject->addHintForMissingSubject($table->getName(), 'fs_storage_path_prefix'); |
||
| 130 | } |
||
| 131 | } |
||
| 132 | |||
| 133 | if ($schema->hasTable('twofactor_providers')) { |
||
| 134 | $table = $schema->getTable('twofactor_providers'); |
||
| 135 | |||
| 136 | if (!$table->hasIndex('twofactor_providers_uid')) { |
||
| 137 | $subject->addHintForMissingSubject($table->getName(), 'twofactor_providers_uid'); |
||
| 138 | } |
||
| 139 | } |
||
| 140 | |||
| 141 | if ($schema->hasTable('login_flow_v2')) { |
||
| 142 | $table = $schema->getTable('login_flow_v2'); |
||
| 143 | |||
| 144 | if (!$table->hasIndex('poll_token')) { |
||
| 145 | $subject->addHintForMissingSubject($table->getName(), 'poll_token'); |
||
| 146 | } |
||
| 147 | if (!$table->hasIndex('login_token')) { |
||
| 148 | $subject->addHintForMissingSubject($table->getName(), 'login_token'); |
||
| 149 | } |
||
| 150 | if (!$table->hasIndex('timestamp')) { |
||
| 151 | $subject->addHintForMissingSubject($table->getName(), 'timestamp'); |
||
| 152 | } |
||
| 153 | } |
||
| 154 | |||
| 155 | if ($schema->hasTable('whats_new')) { |
||
| 156 | $table = $schema->getTable('whats_new'); |
||
| 157 | |||
| 158 | if (!$table->hasIndex('version')) { |
||
| 159 | $subject->addHintForMissingSubject($table->getName(), 'version'); |
||
| 160 | } |
||
| 161 | } |
||
| 162 | |||
| 163 | if ($schema->hasTable('cards')) { |
||
| 164 | $table = $schema->getTable('cards'); |
||
| 165 | |||
| 166 | if (!$table->hasIndex('cards_abid')) { |
||
| 167 | $subject->addHintForMissingSubject($table->getName(), 'cards_abid'); |
||
| 168 | } |
||
| 169 | |||
| 170 | if (!$table->hasIndex('cards_abiduri')) { |
||
| 171 | $subject->addHintForMissingSubject($table->getName(), 'cards_abiduri'); |
||
| 172 | } |
||
| 173 | } |
||
| 174 | |||
| 175 | if ($schema->hasTable('cards_properties')) { |
||
| 176 | $table = $schema->getTable('cards_properties'); |
||
| 177 | |||
| 178 | if (!$table->hasIndex('cards_prop_abid')) { |
||
| 179 | $subject->addHintForMissingSubject($table->getName(), 'cards_prop_abid'); |
||
| 180 | } |
||
| 181 | } |
||
| 182 | |||
| 183 | if ($schema->hasTable('calendarobjects_props')) { |
||
| 184 | $table = $schema->getTable('calendarobjects_props'); |
||
| 185 | |||
| 186 | if (!$table->hasIndex('calendarobject_calid_index')) { |
||
| 187 | $subject->addHintForMissingSubject($table->getName(), 'calendarobject_calid_index'); |
||
| 188 | } |
||
| 189 | } |
||
| 190 | |||
| 191 | if ($schema->hasTable('schedulingobjects')) { |
||
| 192 | $table = $schema->getTable('schedulingobjects'); |
||
| 193 | if (!$table->hasIndex('schedulobj_principuri_index')) { |
||
| 194 | $subject->addHintForMissingSubject($table->getName(), 'schedulobj_principuri_index'); |
||
| 195 | } |
||
| 196 | } |
||
| 197 | |||
| 198 | if ($schema->hasTable('properties')) { |
||
| 199 | $table = $schema->getTable('properties'); |
||
| 200 | if (!$table->hasIndex('properties_path_index')) { |
||
| 201 | $subject->addHintForMissingSubject($table->getName(), 'properties_path_index'); |
||
| 202 | } |
||
| 203 | if (!$table->hasIndex('properties_pathonly_index')) { |
||
| 204 | $subject->addHintForMissingSubject($table->getName(), 'properties_pathonly_index'); |
||
| 205 | } |
||
| 206 | } |
||
| 207 | |||
| 208 | if ($schema->hasTable('jobs')) { |
||
| 209 | $table = $schema->getTable('jobs'); |
||
| 210 | if (!$table->hasIndex('job_lastcheck_reserved')) { |
||
| 211 | $subject->addHintForMissingSubject($table->getName(), 'job_lastcheck_reserved'); |
||
| 212 | } |
||
| 213 | } |
||
| 214 | |||
| 215 | if ($schema->hasTable('direct_edit')) { |
||
| 216 | $table = $schema->getTable('direct_edit'); |
||
| 217 | if (!$table->hasIndex('direct_edit_timestamp')) { |
||
| 218 | $subject->addHintForMissingSubject($table->getName(), 'direct_edit_timestamp'); |
||
| 219 | } |
||
| 220 | } |
||
| 221 | |||
| 222 | if ($schema->hasTable('preferences')) { |
||
| 223 | $table = $schema->getTable('preferences'); |
||
| 224 | if (!$table->hasIndex('preferences_app_key')) { |
||
| 225 | $subject->addHintForMissingSubject($table->getName(), 'preferences_app_key'); |
||
| 226 | } |
||
| 227 | } |
||
| 228 | } |
||
| 229 | ); |
||
| 230 | |||
| 231 | $oldEventDispatcher->addListener(IDBConnection::CHECK_MISSING_PRIMARY_KEYS_EVENT, |
||
| 232 | function (GenericEvent $event) use ($container) { |
||
| 233 | /** @var MissingPrimaryKeyInformation $subject */ |
||
| 234 | $subject = $event->getSubject(); |
||
| 235 | |||
| 236 | $schema = new SchemaWrapper($container->query(Connection::class)); |
||
| 237 | |||
| 238 | if ($schema->hasTable('federated_reshares')) { |
||
| 239 | $table = $schema->getTable('federated_reshares'); |
||
| 240 | |||
| 241 | if (!$table->hasPrimaryKey()) { |
||
| 242 | $subject->addHintForMissingSubject($table->getName()); |
||
| 243 | } |
||
| 244 | } |
||
| 245 | |||
| 246 | if ($schema->hasTable('systemtag_object_mapping')) { |
||
| 247 | $table = $schema->getTable('systemtag_object_mapping'); |
||
| 248 | |||
| 249 | if (!$table->hasPrimaryKey()) { |
||
| 250 | $subject->addHintForMissingSubject($table->getName()); |
||
| 251 | } |
||
| 252 | } |
||
| 253 | |||
| 254 | if ($schema->hasTable('comments_read_markers')) { |
||
| 255 | $table = $schema->getTable('comments_read_markers'); |
||
| 256 | |||
| 257 | if (!$table->hasPrimaryKey()) { |
||
| 258 | $subject->addHintForMissingSubject($table->getName()); |
||
| 259 | } |
||
| 260 | } |
||
| 261 | |||
| 262 | if ($schema->hasTable('collres_resources')) { |
||
| 263 | $table = $schema->getTable('collres_resources'); |
||
| 264 | |||
| 265 | if (!$table->hasPrimaryKey()) { |
||
| 266 | $subject->addHintForMissingSubject($table->getName()); |
||
| 267 | } |
||
| 268 | } |
||
| 269 | |||
| 270 | if ($schema->hasTable('collres_accesscache')) { |
||
| 271 | $table = $schema->getTable('collres_accesscache'); |
||
| 272 | |||
| 273 | if (!$table->hasPrimaryKey()) { |
||
| 274 | $subject->addHintForMissingSubject($table->getName()); |
||
| 275 | } |
||
| 276 | } |
||
| 277 | |||
| 278 | if ($schema->hasTable('filecache_extended')) { |
||
| 279 | $table = $schema->getTable('filecache_extended'); |
||
| 280 | |||
| 281 | if (!$table->hasPrimaryKey()) { |
||
| 282 | $subject->addHintForMissingSubject($table->getName()); |
||
| 283 | } |
||
| 284 | } |
||
| 285 | } |
||
| 286 | ); |
||
| 287 | |||
| 288 | $oldEventDispatcher->addListener(IDBConnection::CHECK_MISSING_COLUMNS_EVENT, |
||
| 289 | function (GenericEvent $event) use ($container) { |
||
| 290 | /** @var MissingColumnInformation $subject */ |
||
| 291 | $subject = $event->getSubject(); |
||
| 292 | |||
| 293 | $schema = new SchemaWrapper($container->query(Connection::class)); |
||
| 294 | |||
| 295 | if ($schema->hasTable('comments')) { |
||
| 296 | $table = $schema->getTable('comments'); |
||
| 297 | |||
| 298 | if (!$table->hasColumn('reference_id')) { |
||
| 299 | $subject->addHintForMissingColumn($table->getName(), 'reference_id'); |
||
| 300 | } |
||
| 301 | } |
||
| 302 | } |
||
| 303 | ); |
||
| 304 | |||
| 305 | $eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeActivityListener::class); |
||
| 306 | $eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeNotificationsListener::class); |
||
| 307 | $eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeEmailListener::class); |
||
| 308 | $eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeActivityListener::class); |
||
| 309 | $eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeNotificationsListener::class); |
||
| 310 | $eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeEmailListener::class); |
||
| 311 | $eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedStoreCleanupListener::class); |
||
| 312 | $eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedTokenCleanupListener::class); |
||
| 313 | $eventDispatcher->addServiceListener(BeforeUserDeletedEvent::class, UserDeletedFilesCleanupListener::class); |
||
| 314 | $eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedFilesCleanupListener::class); |
||
| 315 | $eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedWebAuthnCleanupListener::class); |
||
| 316 | |||
| 317 | // Metadata |
||
| 318 | /** @var IConfig $config */ |
||
| 319 | $config = $container->get(IConfig::class); |
||
| 320 | if ($config->getSystemValueBool('enable_file_metadata', true)) { |
||
| 321 | $eventDispatcher = \OC::$server->get(IEventDispatcher::class); |
||
| 322 | $eventDispatcher->addServiceListener(NodeDeletedEvent::class, FileEventListener::class); |
||
| 323 | $eventDispatcher->addServiceListener(NodeRemovedFromCache::class, FileEventListener::class); |
||
| 324 | $eventDispatcher->addServiceListener(NodeWrittenEvent::class, FileEventListener::class); |
||
| 325 | } |
||
| 328 |
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.