Passed
Push — master ( 9a7a8b...7b250d )
by Morris
10:42 queued 12s
created
lib/private/Server.php 2 patches
Indentation   +2092 added lines, -2092 removed lines patch added patch discarded remove patch
@@ -244,2101 +244,2101 @@
 block discarded – undo
244 244
  */
245 245
 class Server extends ServerContainer implements IServerContainer {
246 246
 
247
-	/** @var string */
248
-	private $webRoot;
249
-
250
-	/**
251
-	 * @param string $webRoot
252
-	 * @param \OC\Config $config
253
-	 */
254
-	public function __construct($webRoot, \OC\Config $config) {
255
-		parent::__construct();
256
-		$this->webRoot = $webRoot;
257
-
258
-		// To find out if we are running from CLI or not
259
-		$this->registerParameter('isCLI', \OC::$CLI);
260
-
261
-		$this->registerService(ContainerInterface::class, function (ContainerInterface $c) {
262
-			return $c;
263
-		});
264
-		$this->registerService(\OCP\IServerContainer::class, function (ContainerInterface $c) {
265
-			return $c;
266
-		});
267
-
268
-		$this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
269
-		$this->registerDeprecatedAlias('CalendarManager', \OC\Calendar\Manager::class);
270
-
271
-		$this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class);
272
-		$this->registerDeprecatedAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class);
273
-
274
-		$this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class);
275
-		$this->registerDeprecatedAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class);
276
-
277
-		$this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
278
-		$this->registerDeprecatedAlias('ContactsManager', \OCP\Contacts\IManager::class);
279
-
280
-		$this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class);
281
-
282
-		$this->registerAlias(IActionFactory::class, ActionFactory::class);
283
-
284
-
285
-		$this->registerService(IPreview::class, function (Server $c) {
286
-			return new PreviewManager(
287
-				$c->getConfig(),
288
-				$c->getRootFolder(),
289
-				new \OC\Preview\Storage\Root($c->getRootFolder(), $c->getSystemConfig(), 'preview'),
290
-				$c->getEventDispatcher(),
291
-				$c->getGeneratorHelper(),
292
-				$c->getSession()->get('user_id')
293
-			);
294
-		});
295
-		$this->registerDeprecatedAlias('PreviewManager', IPreview::class);
296
-
297
-		$this->registerService(\OC\Preview\Watcher::class, function (Server $c) {
298
-			return new \OC\Preview\Watcher(
299
-				new \OC\Preview\Storage\Root($c->getRootFolder(), $c->getSystemConfig(), 'preview')
300
-			);
301
-		});
302
-
303
-		$this->registerService(\OCP\Encryption\IManager::class, function (Server $c) {
304
-			$view = new View();
305
-			$util = new Encryption\Util(
306
-				$view,
307
-				$c->getUserManager(),
308
-				$c->getGroupManager(),
309
-				$c->getConfig()
310
-			);
311
-			return new Encryption\Manager(
312
-				$c->getConfig(),
313
-				$c->getLogger(),
314
-				$c->getL10N('core'),
315
-				new View(),
316
-				$util,
317
-				new ArrayCache()
318
-			);
319
-		});
320
-		$this->registerDeprecatedAlias('EncryptionManager', \OCP\Encryption\IManager::class);
321
-
322
-		$this->registerService('EncryptionFileHelper', function (Server $c) {
323
-			$util = new Encryption\Util(
324
-				new View(),
325
-				$c->getUserManager(),
326
-				$c->getGroupManager(),
327
-				$c->getConfig()
328
-			);
329
-			return new Encryption\File(
330
-				$util,
331
-				$c->getRootFolder(),
332
-				$c->getShareManager()
333
-			);
334
-		});
335
-
336
-		$this->registerService('EncryptionKeyStorage', function (Server $c) {
337
-			$view = new View();
338
-			$util = new Encryption\Util(
339
-				$view,
340
-				$c->getUserManager(),
341
-				$c->getGroupManager(),
342
-				$c->getConfig()
343
-			);
344
-
345
-			return new Encryption\Keys\Storage($view, $util);
346
-		});
347
-		$this->registerService('TagMapper', function (Server $c) {
348
-			return new TagMapper($c->getDatabaseConnection());
349
-		});
350
-
351
-		$this->registerService(\OCP\ITagManager::class, function (Server $c) {
352
-			$tagMapper = $c->query('TagMapper');
353
-			return new TagManager($tagMapper, $c->getUserSession());
354
-		});
355
-		$this->registerDeprecatedAlias('TagManager', \OCP\ITagManager::class);
356
-
357
-		$this->registerService('SystemTagManagerFactory', function (Server $c) {
358
-			$config = $c->getConfig();
359
-			$factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
360
-			return new $factoryClass($this);
361
-		});
362
-		$this->registerService(ISystemTagManager::class, function (Server $c) {
363
-			return $c->query('SystemTagManagerFactory')->getManager();
364
-		});
365
-		$this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class);
366
-
367
-		$this->registerService(ISystemTagObjectMapper::class, function (Server $c) {
368
-			return $c->query('SystemTagManagerFactory')->getObjectMapper();
369
-		});
370
-		$this->registerService('RootFolder', function (Server $c) {
371
-			$manager = \OC\Files\Filesystem::getMountManager(null);
372
-			$view = new View();
373
-			$root = new Root(
374
-				$manager,
375
-				$view,
376
-				null,
377
-				$c->getUserMountCache(),
378
-				$this->getLogger(),
379
-				$this->getUserManager()
380
-			);
381
-
382
-			$previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig());
383
-			$previewConnector->connectWatcher();
384
-
385
-			return $root;
386
-		});
387
-		$this->registerService(HookConnector::class, function (Server $c) {
388
-			return new HookConnector(
389
-				$c->query(IRootFolder::class),
390
-				new View(),
391
-				$c->query(\OC\EventDispatcher\SymfonyAdapter::class),
392
-				$c->query(IEventDispatcher::class)
393
-			);
394
-		});
395
-
396
-		$this->registerDeprecatedAlias('SystemTagObjectMapper', ISystemTagObjectMapper::class);
397
-
398
-		$this->registerService(IRootFolder::class, function (Server $c) {
399
-			return new LazyRoot(function () use ($c) {
400
-				return $c->query('RootFolder');
401
-			});
402
-		});
403
-		$this->registerDeprecatedAlias('LazyRootFolder', IRootFolder::class);
404
-
405
-		$this->registerDeprecatedAlias('UserManager', \OC\User\Manager::class);
406
-		$this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
407
-
408
-		$this->registerService(\OCP\IGroupManager::class, function (Server $c) {
409
-			$groupManager = new \OC\Group\Manager($this->getUserManager(), $c->getEventDispatcher(), $this->getLogger());
410
-			$groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
411
-				\OC_Hook::emit('OC_Group', 'pre_createGroup', ['run' => true, 'gid' => $gid]);
412
-
413
-				/** @var IEventDispatcher $dispatcher */
414
-				$dispatcher = $this->query(IEventDispatcher::class);
415
-				$dispatcher->dispatchTyped(new BeforeGroupCreatedEvent($gid));
416
-			});
417
-			$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $group) {
418
-				\OC_Hook::emit('OC_User', 'post_createGroup', ['gid' => $group->getGID()]);
419
-
420
-				/** @var IEventDispatcher $dispatcher */
421
-				$dispatcher = $this->query(IEventDispatcher::class);
422
-				$dispatcher->dispatchTyped(new GroupCreatedEvent($group));
423
-			});
424
-			$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
425
-				\OC_Hook::emit('OC_Group', 'pre_deleteGroup', ['run' => true, 'gid' => $group->getGID()]);
426
-
427
-				/** @var IEventDispatcher $dispatcher */
428
-				$dispatcher = $this->query(IEventDispatcher::class);
429
-				$dispatcher->dispatchTyped(new BeforeGroupDeletedEvent($group));
430
-			});
431
-			$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
432
-				\OC_Hook::emit('OC_User', 'post_deleteGroup', ['gid' => $group->getGID()]);
433
-
434
-				/** @var IEventDispatcher $dispatcher */
435
-				$dispatcher = $this->query(IEventDispatcher::class);
436
-				$dispatcher->dispatchTyped(new GroupDeletedEvent($group));
437
-			});
438
-			$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
439
-				\OC_Hook::emit('OC_Group', 'pre_addToGroup', ['run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()]);
440
-
441
-				/** @var IEventDispatcher $dispatcher */
442
-				$dispatcher = $this->query(IEventDispatcher::class);
443
-				$dispatcher->dispatchTyped(new BeforeUserAddedEvent($group, $user));
444
-			});
445
-			$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
446
-				\OC_Hook::emit('OC_Group', 'post_addToGroup', ['uid' => $user->getUID(), 'gid' => $group->getGID()]);
447
-				//Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
448
-				\OC_Hook::emit('OC_User', 'post_addToGroup', ['uid' => $user->getUID(), 'gid' => $group->getGID()]);
449
-
450
-				/** @var IEventDispatcher $dispatcher */
451
-				$dispatcher = $this->query(IEventDispatcher::class);
452
-				$dispatcher->dispatchTyped(new UserAddedEvent($group, $user));
453
-			});
454
-			$groupManager->listen('\OC\Group', 'preRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
455
-				/** @var IEventDispatcher $dispatcher */
456
-				$dispatcher = $this->query(IEventDispatcher::class);
457
-				$dispatcher->dispatchTyped(new BeforeUserRemovedEvent($group, $user));
458
-			});
459
-			$groupManager->listen('\OC\Group', 'postRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
460
-				/** @var IEventDispatcher $dispatcher */
461
-				$dispatcher = $this->query(IEventDispatcher::class);
462
-				$dispatcher->dispatchTyped(new UserRemovedEvent($group, $user));
463
-			});
464
-			return $groupManager;
465
-		});
466
-		$this->registerDeprecatedAlias('GroupManager', \OCP\IGroupManager::class);
467
-
468
-		$this->registerService(Store::class, function (Server $c) {
469
-			$session = $c->getSession();
470
-			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
471
-				$tokenProvider = $c->query(IProvider::class);
472
-			} else {
473
-				$tokenProvider = null;
474
-			}
475
-			$logger = $c->getLogger();
476
-			return new Store($session, $logger, $tokenProvider);
477
-		});
478
-		$this->registerAlias(IStore::class, Store::class);
479
-		$this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) {
480
-			$dbConnection = $c->getDatabaseConnection();
481
-			return new Authentication\Token\DefaultTokenMapper($dbConnection);
482
-		});
483
-		$this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
484
-
485
-		$this->registerService(\OC\User\Session::class, function (Server $c) {
486
-			$manager = $c->getUserManager();
487
-			$session = new \OC\Session\Memory('');
488
-			$timeFactory = new TimeFactory();
489
-			// Token providers might require a working database. This code
490
-			// might however be called when ownCloud is not yet setup.
491
-			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
492
-				$defaultTokenProvider = $c->query(IProvider::class);
493
-			} else {
494
-				$defaultTokenProvider = null;
495
-			}
496
-
497
-			$legacyDispatcher = $c->getEventDispatcher();
498
-
499
-			$userSession = new \OC\User\Session(
500
-				$manager,
501
-				$session,
502
-				$timeFactory,
503
-				$defaultTokenProvider,
504
-				$c->getConfig(),
505
-				$c->getSecureRandom(),
506
-				$c->getLockdownManager(),
507
-				$c->getLogger(),
508
-				$c->query(IEventDispatcher::class)
509
-			);
510
-			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
511
-				\OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]);
512
-
513
-				/** @var IEventDispatcher $dispatcher */
514
-				$dispatcher = $this->query(IEventDispatcher::class);
515
-				$dispatcher->dispatchTyped(new BeforeUserCreatedEvent($uid, $password));
516
-			});
517
-			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
518
-				/** @var $user \OC\User\User */
519
-				\OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]);
520
-
521
-				/** @var IEventDispatcher $dispatcher */
522
-				$dispatcher = $this->query(IEventDispatcher::class);
523
-				$dispatcher->dispatchTyped(new UserCreatedEvent($user, $password));
524
-			});
525
-			$userSession->listen('\OC\User', 'preDelete', function ($user) use ($legacyDispatcher) {
526
-				/** @var $user \OC\User\User */
527
-				\OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]);
528
-				$legacyDispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user));
529
-
530
-				/** @var IEventDispatcher $dispatcher */
531
-				$dispatcher = $this->query(IEventDispatcher::class);
532
-				$dispatcher->dispatchTyped(new BeforeUserDeletedEvent($user));
533
-			});
534
-			$userSession->listen('\OC\User', 'postDelete', function ($user) {
535
-				/** @var $user \OC\User\User */
536
-				\OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]);
537
-
538
-				/** @var IEventDispatcher $dispatcher */
539
-				$dispatcher = $this->query(IEventDispatcher::class);
540
-				$dispatcher->dispatchTyped(new UserDeletedEvent($user));
541
-			});
542
-			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
543
-				/** @var $user \OC\User\User */
544
-				\OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
545
-
546
-				/** @var IEventDispatcher $dispatcher */
547
-				$dispatcher = $this->query(IEventDispatcher::class);
548
-				$dispatcher->dispatchTyped(new BeforePasswordUpdatedEvent($user, $password, $recoveryPassword));
549
-			});
550
-			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
551
-				/** @var $user \OC\User\User */
552
-				\OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
553
-
554
-				/** @var IEventDispatcher $dispatcher */
555
-				$dispatcher = $this->query(IEventDispatcher::class);
556
-				$dispatcher->dispatchTyped(new PasswordUpdatedEvent($user, $password, $recoveryPassword));
557
-			});
558
-			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
559
-				\OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]);
560
-
561
-				/** @var IEventDispatcher $dispatcher */
562
-				$dispatcher = $this->query(IEventDispatcher::class);
563
-				$dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password));
564
-			});
565
-			$userSession->listen('\OC\User', 'postLogin', function ($user, $password, $isTokenLogin) {
566
-				/** @var $user \OC\User\User */
567
-				\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'isTokenLogin' => $isTokenLogin]);
568
-
569
-				/** @var IEventDispatcher $dispatcher */
570
-				$dispatcher = $this->query(IEventDispatcher::class);
571
-				$dispatcher->dispatchTyped(new UserLoggedInEvent($user, $password, $isTokenLogin));
572
-			});
573
-			$userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) {
574
-				/** @var IEventDispatcher $dispatcher */
575
-				$dispatcher = $this->query(IEventDispatcher::class);
576
-				$dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid));
577
-			});
578
-			$userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
579
-				/** @var $user \OC\User\User */
580
-				\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]);
581
-
582
-				/** @var IEventDispatcher $dispatcher */
583
-				$dispatcher = $this->query(IEventDispatcher::class);
584
-				$dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password));
585
-			});
586
-			$userSession->listen('\OC\User', 'logout', function ($user) {
587
-				\OC_Hook::emit('OC_User', 'logout', []);
588
-
589
-				/** @var IEventDispatcher $dispatcher */
590
-				$dispatcher = $this->query(IEventDispatcher::class);
591
-				$dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user));
592
-			});
593
-			$userSession->listen('\OC\User', 'postLogout', function ($user) {
594
-				/** @var IEventDispatcher $dispatcher */
595
-				$dispatcher = $this->query(IEventDispatcher::class);
596
-				$dispatcher->dispatchTyped(new UserLoggedOutEvent($user));
597
-			});
598
-			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
599
-				/** @var $user \OC\User\User */
600
-				\OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]);
601
-
602
-				/** @var IEventDispatcher $dispatcher */
603
-				$dispatcher = $this->query(IEventDispatcher::class);
604
-				$dispatcher->dispatchTyped(new UserChangedEvent($user, $feature, $value, $oldValue));
605
-			});
606
-			return $userSession;
607
-		});
608
-		$this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class);
609
-		$this->registerDeprecatedAlias('UserSession', \OC\User\Session::class);
610
-
611
-		$this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class);
612
-
613
-		$this->registerAlias(INavigationManager::class, \OC\NavigationManager::class);
614
-		$this->registerDeprecatedAlias('NavigationManager', INavigationManager::class);
615
-
616
-		$this->registerService(\OC\AllConfig::class, function (Server $c) {
617
-			return new \OC\AllConfig(
618
-				$c->getSystemConfig()
619
-			);
620
-		});
621
-		$this->registerDeprecatedAlias('AllConfig', \OC\AllConfig::class);
622
-		$this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
623
-
624
-		$this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
625
-			return new \OC\SystemConfig($config);
626
-		});
627
-		$this->registerDeprecatedAlias('SystemConfig', \OC\SystemConfig::class);
628
-
629
-		$this->registerService(\OC\AppConfig::class, function (Server $c) {
630
-			return new \OC\AppConfig($c->getDatabaseConnection());
631
-		});
632
-		$this->registerDeprecatedAlias('AppConfig', \OC\AppConfig::class);
633
-		$this->registerAlias(IAppConfig::class, \OC\AppConfig::class);
634
-
635
-		$this->registerService(IFactory::class, function (Server $c) {
636
-			return new \OC\L10N\Factory(
637
-				$c->getConfig(),
638
-				$c->getRequest(),
639
-				$c->getUserSession(),
640
-				\OC::$SERVERROOT
641
-			);
642
-		});
643
-		$this->registerDeprecatedAlias('L10NFactory', IFactory::class);
644
-
645
-		$this->registerService(IURLGenerator::class, function (Server $c) {
646
-			$config = $c->getConfig();
647
-			$cacheFactory = $c->getMemCacheFactory();
648
-			$request = $c->getRequest();
649
-			return new \OC\URLGenerator(
650
-				$config,
651
-				$cacheFactory,
652
-				$request
653
-			);
654
-		});
655
-		$this->registerDeprecatedAlias('URLGenerator', IURLGenerator::class);
656
-
657
-		$this->registerDeprecatedAlias('AppFetcher', AppFetcher::class);
658
-		$this->registerDeprecatedAlias('CategoryFetcher', CategoryFetcher::class);
659
-
660
-		$this->registerService(ICache::class, function ($c) {
661
-			return new Cache\File();
662
-		});
663
-		$this->registerDeprecatedAlias('UserCache', ICache::class);
664
-
665
-		$this->registerService(Factory::class, function (Server $c) {
666
-			$arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(),
667
-				ArrayCache::class,
668
-				ArrayCache::class,
669
-				ArrayCache::class
670
-			);
671
-			$config = $c->getConfig();
672
-
673
-			if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
674
-				$v = \OC_App::getAppVersions();
675
-				$v['core'] = implode(',', \OC_Util::getVersion());
676
-				$version = implode(',', $v);
677
-				$instanceId = \OC_Util::getInstanceId();
678
-				$path = \OC::$SERVERROOT;
679
-				$prefix = md5($instanceId . '-' . $version . '-' . $path);
680
-				return new \OC\Memcache\Factory($prefix, $c->getLogger(),
681
-					$config->getSystemValue('memcache.local', null),
682
-					$config->getSystemValue('memcache.distributed', null),
683
-					$config->getSystemValue('memcache.locking', null)
684
-				);
685
-			}
686
-			return $arrayCacheFactory;
687
-		});
688
-		$this->registerDeprecatedAlias('MemCacheFactory', Factory::class);
689
-		$this->registerAlias(ICacheFactory::class, Factory::class);
690
-
691
-		$this->registerService('RedisFactory', function (Server $c) {
692
-			$systemConfig = $c->getSystemConfig();
693
-			return new RedisFactory($systemConfig);
694
-		});
695
-
696
-		$this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
697
-			return new \OC\Activity\Manager(
698
-				$c->getRequest(),
699
-				$c->getUserSession(),
700
-				$c->getConfig(),
701
-				$c->query(IValidator::class)
702
-			);
703
-		});
704
-		$this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class);
705
-
706
-		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
707
-			return new \OC\Activity\EventMerger(
708
-				$c->getL10N('lib')
709
-			);
710
-		});
711
-		$this->registerAlias(IValidator::class, Validator::class);
712
-
713
-		$this->registerService(AvatarManager::class, function (Server $c) {
714
-			return new AvatarManager(
715
-				$c->query(\OC\User\Manager::class),
716
-				$c->getAppDataDir('avatar'),
717
-				$c->getL10N('lib'),
718
-				$c->getLogger(),
719
-				$c->getConfig()
720
-			);
721
-		});
722
-		$this->registerAlias(IAvatarManager::class, AvatarManager::class);
723
-		$this->registerDeprecatedAlias('AvatarManager', AvatarManager::class);
724
-
725
-		$this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
726
-		$this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
727
-
728
-		$this->registerService(\OC\Log::class, function (Server $c) {
729
-			$logType = $c->query(AllConfig::class)->getSystemValue('log_type', 'file');
730
-			$factory = new LogFactory($c, $this->getSystemConfig());
731
-			$logger = $factory->get($logType);
732
-			$registry = $c->query(\OCP\Support\CrashReport\IRegistry::class);
733
-
734
-			return new Log($logger, $this->getSystemConfig(), null, $registry);
735
-		});
736
-		$this->registerAlias(ILogger::class, \OC\Log::class);
737
-		$this->registerDeprecatedAlias('Logger', \OC\Log::class);
738
-		// PSR-3 logger
739
-		$this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class);
740
-
741
-		$this->registerService(ILogFactory::class, function (Server $c) {
742
-			return new LogFactory($c, $this->getSystemConfig());
743
-		});
744
-
745
-		$this->registerService(IJobList::class, function (Server $c) {
746
-			$config = $c->getConfig();
747
-			return new \OC\BackgroundJob\JobList(
748
-				$c->getDatabaseConnection(),
749
-				$config,
750
-				new TimeFactory()
751
-			);
752
-		});
753
-		$this->registerDeprecatedAlias('JobList', IJobList::class);
754
-
755
-		$this->registerService(IRouter::class, function (Server $c) {
756
-			$cacheFactory = $c->getMemCacheFactory();
757
-			$logger = $c->getLogger();
758
-			if ($cacheFactory->isLocalCacheAvailable()) {
759
-				$router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger);
760
-			} else {
761
-				$router = new \OC\Route\Router($logger);
762
-			}
763
-			return $router;
764
-		});
765
-		$this->registerDeprecatedAlias('Router', IRouter::class);
766
-
767
-		$this->registerService(ISearch::class, function ($c) {
768
-			return new Search();
769
-		});
770
-		$this->registerDeprecatedAlias('Search', ISearch::class);
771
-
772
-		$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
773
-			return new \OC\Security\RateLimiting\Backend\MemoryCache(
774
-				$this->getMemCacheFactory(),
775
-				new \OC\AppFramework\Utility\TimeFactory()
776
-			);
777
-		});
778
-
779
-		$this->registerService(\OCP\Security\ISecureRandom::class, function ($c) {
780
-			return new SecureRandom();
781
-		});
782
-		$this->registerDeprecatedAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
783
-
784
-		$this->registerService(ICrypto::class, function (Server $c) {
785
-			return new Crypto($c->getConfig(), $c->getSecureRandom());
786
-		});
787
-		$this->registerDeprecatedAlias('Crypto', ICrypto::class);
788
-
789
-		$this->registerService(IHasher::class, function (Server $c) {
790
-			return new Hasher($c->getConfig());
791
-		});
792
-		$this->registerDeprecatedAlias('Hasher', IHasher::class);
793
-
794
-		$this->registerService(ICredentialsManager::class, function (Server $c) {
795
-			return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
796
-		});
797
-		$this->registerDeprecatedAlias('CredentialsManager', ICredentialsManager::class);
798
-
799
-		$this->registerService(IDBConnection::class, function (Server $c) {
800
-			$systemConfig = $c->getSystemConfig();
801
-			$factory = new \OC\DB\ConnectionFactory($systemConfig);
802
-			$type = $systemConfig->getValue('dbtype', 'sqlite');
803
-			if (!$factory->isValidType($type)) {
804
-				throw new \OC\DatabaseException('Invalid database type');
805
-			}
806
-			$connectionParams = $factory->createConnectionParams();
807
-			$connection = $factory->getConnection($type, $connectionParams);
808
-			$connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
809
-			return $connection;
810
-		});
811
-		$this->registerDeprecatedAlias('DatabaseConnection', IDBConnection::class);
812
-
813
-
814
-		$this->registerService(IClientService::class, function (Server $c) {
815
-			$user = \OC_User::getUser();
816
-			$uid = $user ? $user : null;
817
-			return new ClientService(
818
-				$c->getConfig(),
819
-				$c->getLogger(),
820
-				new \OC\Security\CertificateManager(
821
-					$uid,
822
-					new View(),
823
-					$c->getConfig(),
824
-					$c->getLogger(),
825
-					$c->getSecureRandom()
826
-				)
827
-			);
828
-		});
829
-		$this->registerDeprecatedAlias('HttpClientService', IClientService::class);
830
-		$this->registerService(IEventLogger::class, function (Server $c) {
831
-			$eventLogger = new EventLogger();
832
-			if ($c->getSystemConfig()->getValue('debug', false)) {
833
-				// In debug mode, module is being activated by default
834
-				$eventLogger->activate();
835
-			}
836
-			return $eventLogger;
837
-		});
838
-		$this->registerDeprecatedAlias('EventLogger', IEventLogger::class);
839
-
840
-		$this->registerService(IQueryLogger::class, function (Server $c) {
841
-			$queryLogger = new QueryLogger();
842
-			if ($c->getSystemConfig()->getValue('debug', false)) {
843
-				// In debug mode, module is being activated by default
844
-				$queryLogger->activate();
845
-			}
846
-			return $queryLogger;
847
-		});
848
-		$this->registerDeprecatedAlias('QueryLogger', IQueryLogger::class);
849
-
850
-		$this->registerService(TempManager::class, function (Server $c) {
851
-			return new TempManager(
852
-				$c->getLogger(),
853
-				$c->getConfig()
854
-			);
855
-		});
856
-		$this->registerDeprecatedAlias('TempManager', TempManager::class);
857
-		$this->registerAlias(ITempManager::class, TempManager::class);
858
-
859
-		$this->registerService(AppManager::class, function (Server $c) {
860
-			return new \OC\App\AppManager(
861
-				$c->getUserSession(),
862
-				$c->getConfig(),
863
-				$c->query(\OC\AppConfig::class),
864
-				$c->getGroupManager(),
865
-				$c->getMemCacheFactory(),
866
-				$c->getEventDispatcher(),
867
-				$c->getLogger()
868
-			);
869
-		});
870
-		$this->registerDeprecatedAlias('AppManager', AppManager::class);
871
-		$this->registerAlias(IAppManager::class, AppManager::class);
872
-
873
-		$this->registerService(IDateTimeZone::class, function (Server $c) {
874
-			return new DateTimeZone(
875
-				$c->getConfig(),
876
-				$c->getSession()
877
-			);
878
-		});
879
-		$this->registerDeprecatedAlias('DateTimeZone', IDateTimeZone::class);
880
-
881
-		$this->registerService(IDateTimeFormatter::class, function (Server $c) {
882
-			$language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
883
-
884
-			return new DateTimeFormatter(
885
-				$c->getDateTimeZone()->getTimeZone(),
886
-				$c->getL10N('lib', $language)
887
-			);
888
-		});
889
-		$this->registerDeprecatedAlias('DateTimeFormatter', IDateTimeFormatter::class);
890
-
891
-		$this->registerService(IUserMountCache::class, function (Server $c) {
892
-			$mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
893
-			$listener = new UserMountCacheListener($mountCache);
894
-			$listener->listen($c->getUserManager());
895
-			return $mountCache;
896
-		});
897
-		$this->registerDeprecatedAlias('UserMountCache', IUserMountCache::class);
898
-
899
-		$this->registerService(IMountProviderCollection::class, function (Server $c) {
900
-			$loader = \OC\Files\Filesystem::getLoader();
901
-			$mountCache = $c->query(IUserMountCache::class);
902
-			$manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
903
-
904
-			// builtin providers
905
-
906
-			$config = $c->getConfig();
907
-			$manager->registerProvider(new CacheMountProvider($config));
908
-			$manager->registerHomeProvider(new LocalHomeMountProvider());
909
-			$manager->registerHomeProvider(new ObjectHomeMountProvider($config));
910
-
911
-			return $manager;
912
-		});
913
-		$this->registerDeprecatedAlias('MountConfigManager', IMountProviderCollection::class);
914
-
915
-		$this->registerService('IniWrapper', function ($c) {
916
-			return new IniGetWrapper();
917
-		});
918
-		$this->registerService('AsyncCommandBus', function (Server $c) {
919
-			$busClass = $c->getConfig()->getSystemValue('commandbus');
920
-			if ($busClass) {
921
-				[$app, $class] = explode('::', $busClass, 2);
922
-				if ($c->getAppManager()->isInstalled($app)) {
923
-					\OC_App::loadApp($app);
924
-					return $c->query($class);
925
-				} else {
926
-					throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
927
-				}
928
-			} else {
929
-				$jobList = $c->getJobList();
930
-				return new CronBus($jobList);
931
-			}
932
-		});
933
-		$this->registerAlias(IBus::class, 'AsyncCommandBus');
934
-		$this->registerService('TrustedDomainHelper', function ($c) {
935
-			return new TrustedDomainHelper($this->getConfig());
936
-		});
937
-		$this->registerService(Throttler::class, function (Server $c) {
938
-			return new Throttler(
939
-				$c->getDatabaseConnection(),
940
-				new TimeFactory(),
941
-				$c->getLogger(),
942
-				$c->getConfig()
943
-			);
944
-		});
945
-		$this->registerDeprecatedAlias('Throttler', Throttler::class);
946
-		$this->registerService('IntegrityCodeChecker', function (Server $c) {
947
-			// IConfig and IAppManager requires a working database. This code
948
-			// might however be called when ownCloud is not yet setup.
949
-			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
950
-				$config = $c->getConfig();
951
-				$appManager = $c->getAppManager();
952
-			} else {
953
-				$config = null;
954
-				$appManager = null;
955
-			}
956
-
957
-			return new Checker(
958
-				new EnvironmentHelper(),
959
-				new FileAccessHelper(),
960
-				new AppLocator(),
961
-				$config,
962
-				$c->getMemCacheFactory(),
963
-				$appManager,
964
-				$c->getTempManager(),
965
-				$c->getMimeTypeDetector()
966
-			);
967
-		});
968
-		$this->registerService(\OCP\IRequest::class, function ($c) {
969
-			if (isset($this['urlParams'])) {
970
-				$urlParams = $this['urlParams'];
971
-			} else {
972
-				$urlParams = [];
973
-			}
974
-
975
-			if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
976
-				&& in_array('fakeinput', stream_get_wrappers())
977
-			) {
978
-				$stream = 'fakeinput://data';
979
-			} else {
980
-				$stream = 'php://input';
981
-			}
982
-
983
-			return new Request(
984
-				[
985
-					'get' => $_GET,
986
-					'post' => $_POST,
987
-					'files' => $_FILES,
988
-					'server' => $_SERVER,
989
-					'env' => $_ENV,
990
-					'cookies' => $_COOKIE,
991
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
992
-						? $_SERVER['REQUEST_METHOD']
993
-						: '',
994
-					'urlParams' => $urlParams,
995
-				],
996
-				$this->getSecureRandom(),
997
-				$this->getConfig(),
998
-				$this->getCsrfTokenManager(),
999
-				$stream
1000
-			);
1001
-		});
1002
-		$this->registerDeprecatedAlias('Request', \OCP\IRequest::class);
1003
-
1004
-		$this->registerService(IMailer::class, function (Server $c) {
1005
-			return new Mailer(
1006
-				$c->getConfig(),
1007
-				$c->getLogger(),
1008
-				$c->query(Defaults::class),
1009
-				$c->getURLGenerator(),
1010
-				$c->getL10N('lib'),
1011
-				$c->query(IEventDispatcher::class),
1012
-				$c->getL10NFactory()
1013
-			);
1014
-		});
1015
-		$this->registerDeprecatedAlias('Mailer', IMailer::class);
1016
-
1017
-		$this->registerService('LDAPProvider', function (Server $c) {
1018
-			$config = $c->getConfig();
1019
-			$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
1020
-			if (is_null($factoryClass)) {
1021
-				throw new \Exception('ldapProviderFactory not set');
1022
-			}
1023
-			/** @var \OCP\LDAP\ILDAPProviderFactory $factory */
1024
-			$factory = new $factoryClass($this);
1025
-			return $factory->getLDAPProvider();
1026
-		});
1027
-		$this->registerService(ILockingProvider::class, function (Server $c) {
1028
-			$ini = $c->getIniWrapper();
1029
-			$config = $c->getConfig();
1030
-			$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
1031
-			if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
1032
-				/** @var \OC\Memcache\Factory $memcacheFactory */
1033
-				$memcacheFactory = $c->getMemCacheFactory();
1034
-				$memcache = $memcacheFactory->createLocking('lock');
1035
-				if (!($memcache instanceof \OC\Memcache\NullCache)) {
1036
-					return new MemcacheLockingProvider($memcache, $ttl);
1037
-				}
1038
-				return new DBLockingProvider(
1039
-					$c->getDatabaseConnection(),
1040
-					$c->getLogger(),
1041
-					new TimeFactory(),
1042
-					$ttl,
1043
-					!\OC::$CLI
1044
-				);
1045
-			}
1046
-			return new NoopLockingProvider();
1047
-		});
1048
-		$this->registerDeprecatedAlias('LockingProvider', ILockingProvider::class);
1049
-
1050
-		$this->registerService(IMountManager::class, function () {
1051
-			return new \OC\Files\Mount\Manager();
1052
-		});
1053
-		$this->registerDeprecatedAlias('MountManager', IMountManager::class);
1054
-
1055
-		$this->registerService(IMimeTypeDetector::class, function (Server $c) {
1056
-			return new \OC\Files\Type\Detection(
1057
-				$c->getURLGenerator(),
1058
-				$c->getLogger(),
1059
-				\OC::$configDir,
1060
-				\OC::$SERVERROOT . '/resources/config/'
1061
-			);
1062
-		});
1063
-		$this->registerDeprecatedAlias('MimeTypeDetector', IMimeTypeDetector::class);
1064
-
1065
-		$this->registerService(IMimeTypeLoader::class, function (Server $c) {
1066
-			return new \OC\Files\Type\Loader(
1067
-				$c->getDatabaseConnection()
1068
-			);
1069
-		});
1070
-		$this->registerDeprecatedAlias('MimeTypeLoader', IMimeTypeLoader::class);
1071
-		$this->registerService(BundleFetcher::class, function () {
1072
-			return new BundleFetcher($this->getL10N('lib'));
1073
-		});
1074
-		$this->registerService(\OCP\Notification\IManager::class, function (Server $c) {
1075
-			return new Manager(
1076
-				$c->query(IValidator::class),
1077
-				$c->getLogger()
1078
-			);
1079
-		});
1080
-		$this->registerDeprecatedAlias('NotificationManager', \OCP\Notification\IManager::class);
1081
-
1082
-		$this->registerService(CapabilitiesManager::class, function (Server $c) {
1083
-			$manager = new CapabilitiesManager($c->getLogger());
1084
-			$manager->registerCapability(function () use ($c) {
1085
-				return new \OC\OCS\CoreCapabilities($c->getConfig());
1086
-			});
1087
-			$manager->registerCapability(function () use ($c) {
1088
-				return $c->query(\OC\Security\Bruteforce\Capabilities::class);
1089
-			});
1090
-			return $manager;
1091
-		});
1092
-		$this->registerDeprecatedAlias('CapabilitiesManager', CapabilitiesManager::class);
1093
-
1094
-		$this->registerService(ICommentsManager::class, function (Server $c) {
1095
-			$config = $c->getConfig();
1096
-			$factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
1097
-			/** @var \OCP\Comments\ICommentsManagerFactory $factory */
1098
-			$factory = new $factoryClass($this);
1099
-			$manager = $factory->getManager();
1100
-
1101
-			$manager->registerDisplayNameResolver('user', function ($id) use ($c) {
1102
-				$manager = $c->getUserManager();
1103
-				$user = $manager->get($id);
1104
-				if (is_null($user)) {
1105
-					$l = $c->getL10N('core');
1106
-					$displayName = $l->t('Unknown user');
1107
-				} else {
1108
-					$displayName = $user->getDisplayName();
1109
-				}
1110
-				return $displayName;
1111
-			});
1112
-
1113
-			return $manager;
1114
-		});
1115
-		$this->registerDeprecatedAlias('CommentsManager', ICommentsManager::class);
1116
-
1117
-		$this->registerService('ThemingDefaults', function (Server $c) {
1118
-			/*
247
+    /** @var string */
248
+    private $webRoot;
249
+
250
+    /**
251
+     * @param string $webRoot
252
+     * @param \OC\Config $config
253
+     */
254
+    public function __construct($webRoot, \OC\Config $config) {
255
+        parent::__construct();
256
+        $this->webRoot = $webRoot;
257
+
258
+        // To find out if we are running from CLI or not
259
+        $this->registerParameter('isCLI', \OC::$CLI);
260
+
261
+        $this->registerService(ContainerInterface::class, function (ContainerInterface $c) {
262
+            return $c;
263
+        });
264
+        $this->registerService(\OCP\IServerContainer::class, function (ContainerInterface $c) {
265
+            return $c;
266
+        });
267
+
268
+        $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
269
+        $this->registerDeprecatedAlias('CalendarManager', \OC\Calendar\Manager::class);
270
+
271
+        $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class);
272
+        $this->registerDeprecatedAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class);
273
+
274
+        $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class);
275
+        $this->registerDeprecatedAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class);
276
+
277
+        $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
278
+        $this->registerDeprecatedAlias('ContactsManager', \OCP\Contacts\IManager::class);
279
+
280
+        $this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class);
281
+
282
+        $this->registerAlias(IActionFactory::class, ActionFactory::class);
283
+
284
+
285
+        $this->registerService(IPreview::class, function (Server $c) {
286
+            return new PreviewManager(
287
+                $c->getConfig(),
288
+                $c->getRootFolder(),
289
+                new \OC\Preview\Storage\Root($c->getRootFolder(), $c->getSystemConfig(), 'preview'),
290
+                $c->getEventDispatcher(),
291
+                $c->getGeneratorHelper(),
292
+                $c->getSession()->get('user_id')
293
+            );
294
+        });
295
+        $this->registerDeprecatedAlias('PreviewManager', IPreview::class);
296
+
297
+        $this->registerService(\OC\Preview\Watcher::class, function (Server $c) {
298
+            return new \OC\Preview\Watcher(
299
+                new \OC\Preview\Storage\Root($c->getRootFolder(), $c->getSystemConfig(), 'preview')
300
+            );
301
+        });
302
+
303
+        $this->registerService(\OCP\Encryption\IManager::class, function (Server $c) {
304
+            $view = new View();
305
+            $util = new Encryption\Util(
306
+                $view,
307
+                $c->getUserManager(),
308
+                $c->getGroupManager(),
309
+                $c->getConfig()
310
+            );
311
+            return new Encryption\Manager(
312
+                $c->getConfig(),
313
+                $c->getLogger(),
314
+                $c->getL10N('core'),
315
+                new View(),
316
+                $util,
317
+                new ArrayCache()
318
+            );
319
+        });
320
+        $this->registerDeprecatedAlias('EncryptionManager', \OCP\Encryption\IManager::class);
321
+
322
+        $this->registerService('EncryptionFileHelper', function (Server $c) {
323
+            $util = new Encryption\Util(
324
+                new View(),
325
+                $c->getUserManager(),
326
+                $c->getGroupManager(),
327
+                $c->getConfig()
328
+            );
329
+            return new Encryption\File(
330
+                $util,
331
+                $c->getRootFolder(),
332
+                $c->getShareManager()
333
+            );
334
+        });
335
+
336
+        $this->registerService('EncryptionKeyStorage', function (Server $c) {
337
+            $view = new View();
338
+            $util = new Encryption\Util(
339
+                $view,
340
+                $c->getUserManager(),
341
+                $c->getGroupManager(),
342
+                $c->getConfig()
343
+            );
344
+
345
+            return new Encryption\Keys\Storage($view, $util);
346
+        });
347
+        $this->registerService('TagMapper', function (Server $c) {
348
+            return new TagMapper($c->getDatabaseConnection());
349
+        });
350
+
351
+        $this->registerService(\OCP\ITagManager::class, function (Server $c) {
352
+            $tagMapper = $c->query('TagMapper');
353
+            return new TagManager($tagMapper, $c->getUserSession());
354
+        });
355
+        $this->registerDeprecatedAlias('TagManager', \OCP\ITagManager::class);
356
+
357
+        $this->registerService('SystemTagManagerFactory', function (Server $c) {
358
+            $config = $c->getConfig();
359
+            $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
360
+            return new $factoryClass($this);
361
+        });
362
+        $this->registerService(ISystemTagManager::class, function (Server $c) {
363
+            return $c->query('SystemTagManagerFactory')->getManager();
364
+        });
365
+        $this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class);
366
+
367
+        $this->registerService(ISystemTagObjectMapper::class, function (Server $c) {
368
+            return $c->query('SystemTagManagerFactory')->getObjectMapper();
369
+        });
370
+        $this->registerService('RootFolder', function (Server $c) {
371
+            $manager = \OC\Files\Filesystem::getMountManager(null);
372
+            $view = new View();
373
+            $root = new Root(
374
+                $manager,
375
+                $view,
376
+                null,
377
+                $c->getUserMountCache(),
378
+                $this->getLogger(),
379
+                $this->getUserManager()
380
+            );
381
+
382
+            $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig());
383
+            $previewConnector->connectWatcher();
384
+
385
+            return $root;
386
+        });
387
+        $this->registerService(HookConnector::class, function (Server $c) {
388
+            return new HookConnector(
389
+                $c->query(IRootFolder::class),
390
+                new View(),
391
+                $c->query(\OC\EventDispatcher\SymfonyAdapter::class),
392
+                $c->query(IEventDispatcher::class)
393
+            );
394
+        });
395
+
396
+        $this->registerDeprecatedAlias('SystemTagObjectMapper', ISystemTagObjectMapper::class);
397
+
398
+        $this->registerService(IRootFolder::class, function (Server $c) {
399
+            return new LazyRoot(function () use ($c) {
400
+                return $c->query('RootFolder');
401
+            });
402
+        });
403
+        $this->registerDeprecatedAlias('LazyRootFolder', IRootFolder::class);
404
+
405
+        $this->registerDeprecatedAlias('UserManager', \OC\User\Manager::class);
406
+        $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
407
+
408
+        $this->registerService(\OCP\IGroupManager::class, function (Server $c) {
409
+            $groupManager = new \OC\Group\Manager($this->getUserManager(), $c->getEventDispatcher(), $this->getLogger());
410
+            $groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
411
+                \OC_Hook::emit('OC_Group', 'pre_createGroup', ['run' => true, 'gid' => $gid]);
412
+
413
+                /** @var IEventDispatcher $dispatcher */
414
+                $dispatcher = $this->query(IEventDispatcher::class);
415
+                $dispatcher->dispatchTyped(new BeforeGroupCreatedEvent($gid));
416
+            });
417
+            $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $group) {
418
+                \OC_Hook::emit('OC_User', 'post_createGroup', ['gid' => $group->getGID()]);
419
+
420
+                /** @var IEventDispatcher $dispatcher */
421
+                $dispatcher = $this->query(IEventDispatcher::class);
422
+                $dispatcher->dispatchTyped(new GroupCreatedEvent($group));
423
+            });
424
+            $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
425
+                \OC_Hook::emit('OC_Group', 'pre_deleteGroup', ['run' => true, 'gid' => $group->getGID()]);
426
+
427
+                /** @var IEventDispatcher $dispatcher */
428
+                $dispatcher = $this->query(IEventDispatcher::class);
429
+                $dispatcher->dispatchTyped(new BeforeGroupDeletedEvent($group));
430
+            });
431
+            $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
432
+                \OC_Hook::emit('OC_User', 'post_deleteGroup', ['gid' => $group->getGID()]);
433
+
434
+                /** @var IEventDispatcher $dispatcher */
435
+                $dispatcher = $this->query(IEventDispatcher::class);
436
+                $dispatcher->dispatchTyped(new GroupDeletedEvent($group));
437
+            });
438
+            $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
439
+                \OC_Hook::emit('OC_Group', 'pre_addToGroup', ['run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()]);
440
+
441
+                /** @var IEventDispatcher $dispatcher */
442
+                $dispatcher = $this->query(IEventDispatcher::class);
443
+                $dispatcher->dispatchTyped(new BeforeUserAddedEvent($group, $user));
444
+            });
445
+            $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
446
+                \OC_Hook::emit('OC_Group', 'post_addToGroup', ['uid' => $user->getUID(), 'gid' => $group->getGID()]);
447
+                //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
448
+                \OC_Hook::emit('OC_User', 'post_addToGroup', ['uid' => $user->getUID(), 'gid' => $group->getGID()]);
449
+
450
+                /** @var IEventDispatcher $dispatcher */
451
+                $dispatcher = $this->query(IEventDispatcher::class);
452
+                $dispatcher->dispatchTyped(new UserAddedEvent($group, $user));
453
+            });
454
+            $groupManager->listen('\OC\Group', 'preRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
455
+                /** @var IEventDispatcher $dispatcher */
456
+                $dispatcher = $this->query(IEventDispatcher::class);
457
+                $dispatcher->dispatchTyped(new BeforeUserRemovedEvent($group, $user));
458
+            });
459
+            $groupManager->listen('\OC\Group', 'postRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
460
+                /** @var IEventDispatcher $dispatcher */
461
+                $dispatcher = $this->query(IEventDispatcher::class);
462
+                $dispatcher->dispatchTyped(new UserRemovedEvent($group, $user));
463
+            });
464
+            return $groupManager;
465
+        });
466
+        $this->registerDeprecatedAlias('GroupManager', \OCP\IGroupManager::class);
467
+
468
+        $this->registerService(Store::class, function (Server $c) {
469
+            $session = $c->getSession();
470
+            if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
471
+                $tokenProvider = $c->query(IProvider::class);
472
+            } else {
473
+                $tokenProvider = null;
474
+            }
475
+            $logger = $c->getLogger();
476
+            return new Store($session, $logger, $tokenProvider);
477
+        });
478
+        $this->registerAlias(IStore::class, Store::class);
479
+        $this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) {
480
+            $dbConnection = $c->getDatabaseConnection();
481
+            return new Authentication\Token\DefaultTokenMapper($dbConnection);
482
+        });
483
+        $this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
484
+
485
+        $this->registerService(\OC\User\Session::class, function (Server $c) {
486
+            $manager = $c->getUserManager();
487
+            $session = new \OC\Session\Memory('');
488
+            $timeFactory = new TimeFactory();
489
+            // Token providers might require a working database. This code
490
+            // might however be called when ownCloud is not yet setup.
491
+            if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
492
+                $defaultTokenProvider = $c->query(IProvider::class);
493
+            } else {
494
+                $defaultTokenProvider = null;
495
+            }
496
+
497
+            $legacyDispatcher = $c->getEventDispatcher();
498
+
499
+            $userSession = new \OC\User\Session(
500
+                $manager,
501
+                $session,
502
+                $timeFactory,
503
+                $defaultTokenProvider,
504
+                $c->getConfig(),
505
+                $c->getSecureRandom(),
506
+                $c->getLockdownManager(),
507
+                $c->getLogger(),
508
+                $c->query(IEventDispatcher::class)
509
+            );
510
+            $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
511
+                \OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]);
512
+
513
+                /** @var IEventDispatcher $dispatcher */
514
+                $dispatcher = $this->query(IEventDispatcher::class);
515
+                $dispatcher->dispatchTyped(new BeforeUserCreatedEvent($uid, $password));
516
+            });
517
+            $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
518
+                /** @var $user \OC\User\User */
519
+                \OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]);
520
+
521
+                /** @var IEventDispatcher $dispatcher */
522
+                $dispatcher = $this->query(IEventDispatcher::class);
523
+                $dispatcher->dispatchTyped(new UserCreatedEvent($user, $password));
524
+            });
525
+            $userSession->listen('\OC\User', 'preDelete', function ($user) use ($legacyDispatcher) {
526
+                /** @var $user \OC\User\User */
527
+                \OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]);
528
+                $legacyDispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user));
529
+
530
+                /** @var IEventDispatcher $dispatcher */
531
+                $dispatcher = $this->query(IEventDispatcher::class);
532
+                $dispatcher->dispatchTyped(new BeforeUserDeletedEvent($user));
533
+            });
534
+            $userSession->listen('\OC\User', 'postDelete', function ($user) {
535
+                /** @var $user \OC\User\User */
536
+                \OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]);
537
+
538
+                /** @var IEventDispatcher $dispatcher */
539
+                $dispatcher = $this->query(IEventDispatcher::class);
540
+                $dispatcher->dispatchTyped(new UserDeletedEvent($user));
541
+            });
542
+            $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
543
+                /** @var $user \OC\User\User */
544
+                \OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
545
+
546
+                /** @var IEventDispatcher $dispatcher */
547
+                $dispatcher = $this->query(IEventDispatcher::class);
548
+                $dispatcher->dispatchTyped(new BeforePasswordUpdatedEvent($user, $password, $recoveryPassword));
549
+            });
550
+            $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
551
+                /** @var $user \OC\User\User */
552
+                \OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
553
+
554
+                /** @var IEventDispatcher $dispatcher */
555
+                $dispatcher = $this->query(IEventDispatcher::class);
556
+                $dispatcher->dispatchTyped(new PasswordUpdatedEvent($user, $password, $recoveryPassword));
557
+            });
558
+            $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
559
+                \OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]);
560
+
561
+                /** @var IEventDispatcher $dispatcher */
562
+                $dispatcher = $this->query(IEventDispatcher::class);
563
+                $dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password));
564
+            });
565
+            $userSession->listen('\OC\User', 'postLogin', function ($user, $password, $isTokenLogin) {
566
+                /** @var $user \OC\User\User */
567
+                \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'isTokenLogin' => $isTokenLogin]);
568
+
569
+                /** @var IEventDispatcher $dispatcher */
570
+                $dispatcher = $this->query(IEventDispatcher::class);
571
+                $dispatcher->dispatchTyped(new UserLoggedInEvent($user, $password, $isTokenLogin));
572
+            });
573
+            $userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) {
574
+                /** @var IEventDispatcher $dispatcher */
575
+                $dispatcher = $this->query(IEventDispatcher::class);
576
+                $dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid));
577
+            });
578
+            $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
579
+                /** @var $user \OC\User\User */
580
+                \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]);
581
+
582
+                /** @var IEventDispatcher $dispatcher */
583
+                $dispatcher = $this->query(IEventDispatcher::class);
584
+                $dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password));
585
+            });
586
+            $userSession->listen('\OC\User', 'logout', function ($user) {
587
+                \OC_Hook::emit('OC_User', 'logout', []);
588
+
589
+                /** @var IEventDispatcher $dispatcher */
590
+                $dispatcher = $this->query(IEventDispatcher::class);
591
+                $dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user));
592
+            });
593
+            $userSession->listen('\OC\User', 'postLogout', function ($user) {
594
+                /** @var IEventDispatcher $dispatcher */
595
+                $dispatcher = $this->query(IEventDispatcher::class);
596
+                $dispatcher->dispatchTyped(new UserLoggedOutEvent($user));
597
+            });
598
+            $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
599
+                /** @var $user \OC\User\User */
600
+                \OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]);
601
+
602
+                /** @var IEventDispatcher $dispatcher */
603
+                $dispatcher = $this->query(IEventDispatcher::class);
604
+                $dispatcher->dispatchTyped(new UserChangedEvent($user, $feature, $value, $oldValue));
605
+            });
606
+            return $userSession;
607
+        });
608
+        $this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class);
609
+        $this->registerDeprecatedAlias('UserSession', \OC\User\Session::class);
610
+
611
+        $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class);
612
+
613
+        $this->registerAlias(INavigationManager::class, \OC\NavigationManager::class);
614
+        $this->registerDeprecatedAlias('NavigationManager', INavigationManager::class);
615
+
616
+        $this->registerService(\OC\AllConfig::class, function (Server $c) {
617
+            return new \OC\AllConfig(
618
+                $c->getSystemConfig()
619
+            );
620
+        });
621
+        $this->registerDeprecatedAlias('AllConfig', \OC\AllConfig::class);
622
+        $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
623
+
624
+        $this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
625
+            return new \OC\SystemConfig($config);
626
+        });
627
+        $this->registerDeprecatedAlias('SystemConfig', \OC\SystemConfig::class);
628
+
629
+        $this->registerService(\OC\AppConfig::class, function (Server $c) {
630
+            return new \OC\AppConfig($c->getDatabaseConnection());
631
+        });
632
+        $this->registerDeprecatedAlias('AppConfig', \OC\AppConfig::class);
633
+        $this->registerAlias(IAppConfig::class, \OC\AppConfig::class);
634
+
635
+        $this->registerService(IFactory::class, function (Server $c) {
636
+            return new \OC\L10N\Factory(
637
+                $c->getConfig(),
638
+                $c->getRequest(),
639
+                $c->getUserSession(),
640
+                \OC::$SERVERROOT
641
+            );
642
+        });
643
+        $this->registerDeprecatedAlias('L10NFactory', IFactory::class);
644
+
645
+        $this->registerService(IURLGenerator::class, function (Server $c) {
646
+            $config = $c->getConfig();
647
+            $cacheFactory = $c->getMemCacheFactory();
648
+            $request = $c->getRequest();
649
+            return new \OC\URLGenerator(
650
+                $config,
651
+                $cacheFactory,
652
+                $request
653
+            );
654
+        });
655
+        $this->registerDeprecatedAlias('URLGenerator', IURLGenerator::class);
656
+
657
+        $this->registerDeprecatedAlias('AppFetcher', AppFetcher::class);
658
+        $this->registerDeprecatedAlias('CategoryFetcher', CategoryFetcher::class);
659
+
660
+        $this->registerService(ICache::class, function ($c) {
661
+            return new Cache\File();
662
+        });
663
+        $this->registerDeprecatedAlias('UserCache', ICache::class);
664
+
665
+        $this->registerService(Factory::class, function (Server $c) {
666
+            $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(),
667
+                ArrayCache::class,
668
+                ArrayCache::class,
669
+                ArrayCache::class
670
+            );
671
+            $config = $c->getConfig();
672
+
673
+            if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
674
+                $v = \OC_App::getAppVersions();
675
+                $v['core'] = implode(',', \OC_Util::getVersion());
676
+                $version = implode(',', $v);
677
+                $instanceId = \OC_Util::getInstanceId();
678
+                $path = \OC::$SERVERROOT;
679
+                $prefix = md5($instanceId . '-' . $version . '-' . $path);
680
+                return new \OC\Memcache\Factory($prefix, $c->getLogger(),
681
+                    $config->getSystemValue('memcache.local', null),
682
+                    $config->getSystemValue('memcache.distributed', null),
683
+                    $config->getSystemValue('memcache.locking', null)
684
+                );
685
+            }
686
+            return $arrayCacheFactory;
687
+        });
688
+        $this->registerDeprecatedAlias('MemCacheFactory', Factory::class);
689
+        $this->registerAlias(ICacheFactory::class, Factory::class);
690
+
691
+        $this->registerService('RedisFactory', function (Server $c) {
692
+            $systemConfig = $c->getSystemConfig();
693
+            return new RedisFactory($systemConfig);
694
+        });
695
+
696
+        $this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
697
+            return new \OC\Activity\Manager(
698
+                $c->getRequest(),
699
+                $c->getUserSession(),
700
+                $c->getConfig(),
701
+                $c->query(IValidator::class)
702
+            );
703
+        });
704
+        $this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class);
705
+
706
+        $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
707
+            return new \OC\Activity\EventMerger(
708
+                $c->getL10N('lib')
709
+            );
710
+        });
711
+        $this->registerAlias(IValidator::class, Validator::class);
712
+
713
+        $this->registerService(AvatarManager::class, function (Server $c) {
714
+            return new AvatarManager(
715
+                $c->query(\OC\User\Manager::class),
716
+                $c->getAppDataDir('avatar'),
717
+                $c->getL10N('lib'),
718
+                $c->getLogger(),
719
+                $c->getConfig()
720
+            );
721
+        });
722
+        $this->registerAlias(IAvatarManager::class, AvatarManager::class);
723
+        $this->registerDeprecatedAlias('AvatarManager', AvatarManager::class);
724
+
725
+        $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
726
+        $this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
727
+
728
+        $this->registerService(\OC\Log::class, function (Server $c) {
729
+            $logType = $c->query(AllConfig::class)->getSystemValue('log_type', 'file');
730
+            $factory = new LogFactory($c, $this->getSystemConfig());
731
+            $logger = $factory->get($logType);
732
+            $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class);
733
+
734
+            return new Log($logger, $this->getSystemConfig(), null, $registry);
735
+        });
736
+        $this->registerAlias(ILogger::class, \OC\Log::class);
737
+        $this->registerDeprecatedAlias('Logger', \OC\Log::class);
738
+        // PSR-3 logger
739
+        $this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class);
740
+
741
+        $this->registerService(ILogFactory::class, function (Server $c) {
742
+            return new LogFactory($c, $this->getSystemConfig());
743
+        });
744
+
745
+        $this->registerService(IJobList::class, function (Server $c) {
746
+            $config = $c->getConfig();
747
+            return new \OC\BackgroundJob\JobList(
748
+                $c->getDatabaseConnection(),
749
+                $config,
750
+                new TimeFactory()
751
+            );
752
+        });
753
+        $this->registerDeprecatedAlias('JobList', IJobList::class);
754
+
755
+        $this->registerService(IRouter::class, function (Server $c) {
756
+            $cacheFactory = $c->getMemCacheFactory();
757
+            $logger = $c->getLogger();
758
+            if ($cacheFactory->isLocalCacheAvailable()) {
759
+                $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger);
760
+            } else {
761
+                $router = new \OC\Route\Router($logger);
762
+            }
763
+            return $router;
764
+        });
765
+        $this->registerDeprecatedAlias('Router', IRouter::class);
766
+
767
+        $this->registerService(ISearch::class, function ($c) {
768
+            return new Search();
769
+        });
770
+        $this->registerDeprecatedAlias('Search', ISearch::class);
771
+
772
+        $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
773
+            return new \OC\Security\RateLimiting\Backend\MemoryCache(
774
+                $this->getMemCacheFactory(),
775
+                new \OC\AppFramework\Utility\TimeFactory()
776
+            );
777
+        });
778
+
779
+        $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) {
780
+            return new SecureRandom();
781
+        });
782
+        $this->registerDeprecatedAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
783
+
784
+        $this->registerService(ICrypto::class, function (Server $c) {
785
+            return new Crypto($c->getConfig(), $c->getSecureRandom());
786
+        });
787
+        $this->registerDeprecatedAlias('Crypto', ICrypto::class);
788
+
789
+        $this->registerService(IHasher::class, function (Server $c) {
790
+            return new Hasher($c->getConfig());
791
+        });
792
+        $this->registerDeprecatedAlias('Hasher', IHasher::class);
793
+
794
+        $this->registerService(ICredentialsManager::class, function (Server $c) {
795
+            return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
796
+        });
797
+        $this->registerDeprecatedAlias('CredentialsManager', ICredentialsManager::class);
798
+
799
+        $this->registerService(IDBConnection::class, function (Server $c) {
800
+            $systemConfig = $c->getSystemConfig();
801
+            $factory = new \OC\DB\ConnectionFactory($systemConfig);
802
+            $type = $systemConfig->getValue('dbtype', 'sqlite');
803
+            if (!$factory->isValidType($type)) {
804
+                throw new \OC\DatabaseException('Invalid database type');
805
+            }
806
+            $connectionParams = $factory->createConnectionParams();
807
+            $connection = $factory->getConnection($type, $connectionParams);
808
+            $connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
809
+            return $connection;
810
+        });
811
+        $this->registerDeprecatedAlias('DatabaseConnection', IDBConnection::class);
812
+
813
+
814
+        $this->registerService(IClientService::class, function (Server $c) {
815
+            $user = \OC_User::getUser();
816
+            $uid = $user ? $user : null;
817
+            return new ClientService(
818
+                $c->getConfig(),
819
+                $c->getLogger(),
820
+                new \OC\Security\CertificateManager(
821
+                    $uid,
822
+                    new View(),
823
+                    $c->getConfig(),
824
+                    $c->getLogger(),
825
+                    $c->getSecureRandom()
826
+                )
827
+            );
828
+        });
829
+        $this->registerDeprecatedAlias('HttpClientService', IClientService::class);
830
+        $this->registerService(IEventLogger::class, function (Server $c) {
831
+            $eventLogger = new EventLogger();
832
+            if ($c->getSystemConfig()->getValue('debug', false)) {
833
+                // In debug mode, module is being activated by default
834
+                $eventLogger->activate();
835
+            }
836
+            return $eventLogger;
837
+        });
838
+        $this->registerDeprecatedAlias('EventLogger', IEventLogger::class);
839
+
840
+        $this->registerService(IQueryLogger::class, function (Server $c) {
841
+            $queryLogger = new QueryLogger();
842
+            if ($c->getSystemConfig()->getValue('debug', false)) {
843
+                // In debug mode, module is being activated by default
844
+                $queryLogger->activate();
845
+            }
846
+            return $queryLogger;
847
+        });
848
+        $this->registerDeprecatedAlias('QueryLogger', IQueryLogger::class);
849
+
850
+        $this->registerService(TempManager::class, function (Server $c) {
851
+            return new TempManager(
852
+                $c->getLogger(),
853
+                $c->getConfig()
854
+            );
855
+        });
856
+        $this->registerDeprecatedAlias('TempManager', TempManager::class);
857
+        $this->registerAlias(ITempManager::class, TempManager::class);
858
+
859
+        $this->registerService(AppManager::class, function (Server $c) {
860
+            return new \OC\App\AppManager(
861
+                $c->getUserSession(),
862
+                $c->getConfig(),
863
+                $c->query(\OC\AppConfig::class),
864
+                $c->getGroupManager(),
865
+                $c->getMemCacheFactory(),
866
+                $c->getEventDispatcher(),
867
+                $c->getLogger()
868
+            );
869
+        });
870
+        $this->registerDeprecatedAlias('AppManager', AppManager::class);
871
+        $this->registerAlias(IAppManager::class, AppManager::class);
872
+
873
+        $this->registerService(IDateTimeZone::class, function (Server $c) {
874
+            return new DateTimeZone(
875
+                $c->getConfig(),
876
+                $c->getSession()
877
+            );
878
+        });
879
+        $this->registerDeprecatedAlias('DateTimeZone', IDateTimeZone::class);
880
+
881
+        $this->registerService(IDateTimeFormatter::class, function (Server $c) {
882
+            $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
883
+
884
+            return new DateTimeFormatter(
885
+                $c->getDateTimeZone()->getTimeZone(),
886
+                $c->getL10N('lib', $language)
887
+            );
888
+        });
889
+        $this->registerDeprecatedAlias('DateTimeFormatter', IDateTimeFormatter::class);
890
+
891
+        $this->registerService(IUserMountCache::class, function (Server $c) {
892
+            $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
893
+            $listener = new UserMountCacheListener($mountCache);
894
+            $listener->listen($c->getUserManager());
895
+            return $mountCache;
896
+        });
897
+        $this->registerDeprecatedAlias('UserMountCache', IUserMountCache::class);
898
+
899
+        $this->registerService(IMountProviderCollection::class, function (Server $c) {
900
+            $loader = \OC\Files\Filesystem::getLoader();
901
+            $mountCache = $c->query(IUserMountCache::class);
902
+            $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
903
+
904
+            // builtin providers
905
+
906
+            $config = $c->getConfig();
907
+            $manager->registerProvider(new CacheMountProvider($config));
908
+            $manager->registerHomeProvider(new LocalHomeMountProvider());
909
+            $manager->registerHomeProvider(new ObjectHomeMountProvider($config));
910
+
911
+            return $manager;
912
+        });
913
+        $this->registerDeprecatedAlias('MountConfigManager', IMountProviderCollection::class);
914
+
915
+        $this->registerService('IniWrapper', function ($c) {
916
+            return new IniGetWrapper();
917
+        });
918
+        $this->registerService('AsyncCommandBus', function (Server $c) {
919
+            $busClass = $c->getConfig()->getSystemValue('commandbus');
920
+            if ($busClass) {
921
+                [$app, $class] = explode('::', $busClass, 2);
922
+                if ($c->getAppManager()->isInstalled($app)) {
923
+                    \OC_App::loadApp($app);
924
+                    return $c->query($class);
925
+                } else {
926
+                    throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
927
+                }
928
+            } else {
929
+                $jobList = $c->getJobList();
930
+                return new CronBus($jobList);
931
+            }
932
+        });
933
+        $this->registerAlias(IBus::class, 'AsyncCommandBus');
934
+        $this->registerService('TrustedDomainHelper', function ($c) {
935
+            return new TrustedDomainHelper($this->getConfig());
936
+        });
937
+        $this->registerService(Throttler::class, function (Server $c) {
938
+            return new Throttler(
939
+                $c->getDatabaseConnection(),
940
+                new TimeFactory(),
941
+                $c->getLogger(),
942
+                $c->getConfig()
943
+            );
944
+        });
945
+        $this->registerDeprecatedAlias('Throttler', Throttler::class);
946
+        $this->registerService('IntegrityCodeChecker', function (Server $c) {
947
+            // IConfig and IAppManager requires a working database. This code
948
+            // might however be called when ownCloud is not yet setup.
949
+            if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
950
+                $config = $c->getConfig();
951
+                $appManager = $c->getAppManager();
952
+            } else {
953
+                $config = null;
954
+                $appManager = null;
955
+            }
956
+
957
+            return new Checker(
958
+                new EnvironmentHelper(),
959
+                new FileAccessHelper(),
960
+                new AppLocator(),
961
+                $config,
962
+                $c->getMemCacheFactory(),
963
+                $appManager,
964
+                $c->getTempManager(),
965
+                $c->getMimeTypeDetector()
966
+            );
967
+        });
968
+        $this->registerService(\OCP\IRequest::class, function ($c) {
969
+            if (isset($this['urlParams'])) {
970
+                $urlParams = $this['urlParams'];
971
+            } else {
972
+                $urlParams = [];
973
+            }
974
+
975
+            if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
976
+                && in_array('fakeinput', stream_get_wrappers())
977
+            ) {
978
+                $stream = 'fakeinput://data';
979
+            } else {
980
+                $stream = 'php://input';
981
+            }
982
+
983
+            return new Request(
984
+                [
985
+                    'get' => $_GET,
986
+                    'post' => $_POST,
987
+                    'files' => $_FILES,
988
+                    'server' => $_SERVER,
989
+                    'env' => $_ENV,
990
+                    'cookies' => $_COOKIE,
991
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
992
+                        ? $_SERVER['REQUEST_METHOD']
993
+                        : '',
994
+                    'urlParams' => $urlParams,
995
+                ],
996
+                $this->getSecureRandom(),
997
+                $this->getConfig(),
998
+                $this->getCsrfTokenManager(),
999
+                $stream
1000
+            );
1001
+        });
1002
+        $this->registerDeprecatedAlias('Request', \OCP\IRequest::class);
1003
+
1004
+        $this->registerService(IMailer::class, function (Server $c) {
1005
+            return new Mailer(
1006
+                $c->getConfig(),
1007
+                $c->getLogger(),
1008
+                $c->query(Defaults::class),
1009
+                $c->getURLGenerator(),
1010
+                $c->getL10N('lib'),
1011
+                $c->query(IEventDispatcher::class),
1012
+                $c->getL10NFactory()
1013
+            );
1014
+        });
1015
+        $this->registerDeprecatedAlias('Mailer', IMailer::class);
1016
+
1017
+        $this->registerService('LDAPProvider', function (Server $c) {
1018
+            $config = $c->getConfig();
1019
+            $factoryClass = $config->getSystemValue('ldapProviderFactory', null);
1020
+            if (is_null($factoryClass)) {
1021
+                throw new \Exception('ldapProviderFactory not set');
1022
+            }
1023
+            /** @var \OCP\LDAP\ILDAPProviderFactory $factory */
1024
+            $factory = new $factoryClass($this);
1025
+            return $factory->getLDAPProvider();
1026
+        });
1027
+        $this->registerService(ILockingProvider::class, function (Server $c) {
1028
+            $ini = $c->getIniWrapper();
1029
+            $config = $c->getConfig();
1030
+            $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
1031
+            if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
1032
+                /** @var \OC\Memcache\Factory $memcacheFactory */
1033
+                $memcacheFactory = $c->getMemCacheFactory();
1034
+                $memcache = $memcacheFactory->createLocking('lock');
1035
+                if (!($memcache instanceof \OC\Memcache\NullCache)) {
1036
+                    return new MemcacheLockingProvider($memcache, $ttl);
1037
+                }
1038
+                return new DBLockingProvider(
1039
+                    $c->getDatabaseConnection(),
1040
+                    $c->getLogger(),
1041
+                    new TimeFactory(),
1042
+                    $ttl,
1043
+                    !\OC::$CLI
1044
+                );
1045
+            }
1046
+            return new NoopLockingProvider();
1047
+        });
1048
+        $this->registerDeprecatedAlias('LockingProvider', ILockingProvider::class);
1049
+
1050
+        $this->registerService(IMountManager::class, function () {
1051
+            return new \OC\Files\Mount\Manager();
1052
+        });
1053
+        $this->registerDeprecatedAlias('MountManager', IMountManager::class);
1054
+
1055
+        $this->registerService(IMimeTypeDetector::class, function (Server $c) {
1056
+            return new \OC\Files\Type\Detection(
1057
+                $c->getURLGenerator(),
1058
+                $c->getLogger(),
1059
+                \OC::$configDir,
1060
+                \OC::$SERVERROOT . '/resources/config/'
1061
+            );
1062
+        });
1063
+        $this->registerDeprecatedAlias('MimeTypeDetector', IMimeTypeDetector::class);
1064
+
1065
+        $this->registerService(IMimeTypeLoader::class, function (Server $c) {
1066
+            return new \OC\Files\Type\Loader(
1067
+                $c->getDatabaseConnection()
1068
+            );
1069
+        });
1070
+        $this->registerDeprecatedAlias('MimeTypeLoader', IMimeTypeLoader::class);
1071
+        $this->registerService(BundleFetcher::class, function () {
1072
+            return new BundleFetcher($this->getL10N('lib'));
1073
+        });
1074
+        $this->registerService(\OCP\Notification\IManager::class, function (Server $c) {
1075
+            return new Manager(
1076
+                $c->query(IValidator::class),
1077
+                $c->getLogger()
1078
+            );
1079
+        });
1080
+        $this->registerDeprecatedAlias('NotificationManager', \OCP\Notification\IManager::class);
1081
+
1082
+        $this->registerService(CapabilitiesManager::class, function (Server $c) {
1083
+            $manager = new CapabilitiesManager($c->getLogger());
1084
+            $manager->registerCapability(function () use ($c) {
1085
+                return new \OC\OCS\CoreCapabilities($c->getConfig());
1086
+            });
1087
+            $manager->registerCapability(function () use ($c) {
1088
+                return $c->query(\OC\Security\Bruteforce\Capabilities::class);
1089
+            });
1090
+            return $manager;
1091
+        });
1092
+        $this->registerDeprecatedAlias('CapabilitiesManager', CapabilitiesManager::class);
1093
+
1094
+        $this->registerService(ICommentsManager::class, function (Server $c) {
1095
+            $config = $c->getConfig();
1096
+            $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
1097
+            /** @var \OCP\Comments\ICommentsManagerFactory $factory */
1098
+            $factory = new $factoryClass($this);
1099
+            $manager = $factory->getManager();
1100
+
1101
+            $manager->registerDisplayNameResolver('user', function ($id) use ($c) {
1102
+                $manager = $c->getUserManager();
1103
+                $user = $manager->get($id);
1104
+                if (is_null($user)) {
1105
+                    $l = $c->getL10N('core');
1106
+                    $displayName = $l->t('Unknown user');
1107
+                } else {
1108
+                    $displayName = $user->getDisplayName();
1109
+                }
1110
+                return $displayName;
1111
+            });
1112
+
1113
+            return $manager;
1114
+        });
1115
+        $this->registerDeprecatedAlias('CommentsManager', ICommentsManager::class);
1116
+
1117
+        $this->registerService('ThemingDefaults', function (Server $c) {
1118
+            /*
1119 1119
 			 * Dark magic for autoloader.
1120 1120
 			 * If we do a class_exists it will try to load the class which will
1121 1121
 			 * make composer cache the result. Resulting in errors when enabling
1122 1122
 			 * the theming app.
1123 1123
 			 */
1124
-			$prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
1125
-			if (isset($prefixes['OCA\\Theming\\'])) {
1126
-				$classExists = true;
1127
-			} else {
1128
-				$classExists = false;
1129
-			}
1130
-
1131
-			if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
1132
-				return new ThemingDefaults(
1133
-					$c->getConfig(),
1134
-					$c->getL10N('theming'),
1135
-					$c->getURLGenerator(),
1136
-					$c->getMemCacheFactory(),
1137
-					new Util($c->getConfig(), $this->getAppManager(), $c->getAppDataDir('theming')),
1138
-					new ImageManager($c->getConfig(), $c->getAppDataDir('theming'), $c->getURLGenerator(), $this->getMemCacheFactory(), $this->getLogger()),
1139
-					$c->getAppManager(),
1140
-					$c->getNavigationManager()
1141
-				);
1142
-			}
1143
-			return new \OC_Defaults();
1144
-		});
1145
-		$this->registerService(SCSSCacher::class, function (Server $c) {
1146
-			return new SCSSCacher(
1147
-				$c->getLogger(),
1148
-				$c->query(\OC\Files\AppData\Factory::class),
1149
-				$c->getURLGenerator(),
1150
-				$c->getConfig(),
1151
-				$c->getThemingDefaults(),
1152
-				\OC::$SERVERROOT,
1153
-				$this->getMemCacheFactory(),
1154
-				$c->query(IconsCacher::class),
1155
-				new TimeFactory()
1156
-			);
1157
-		});
1158
-		$this->registerService(JSCombiner::class, function (Server $c) {
1159
-			return new JSCombiner(
1160
-				$c->getAppDataDir('js'),
1161
-				$c->getURLGenerator(),
1162
-				$this->getMemCacheFactory(),
1163
-				$c->getSystemConfig(),
1164
-				$c->getLogger()
1165
-			);
1166
-		});
1167
-		$this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class);
1168
-		$this->registerDeprecatedAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class);
1169
-		$this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class);
1170
-
1171
-		$this->registerService('CryptoWrapper', function (Server $c) {
1172
-			// FIXME: Instantiiated here due to cyclic dependency
1173
-			$request = new Request(
1174
-				[
1175
-					'get' => $_GET,
1176
-					'post' => $_POST,
1177
-					'files' => $_FILES,
1178
-					'server' => $_SERVER,
1179
-					'env' => $_ENV,
1180
-					'cookies' => $_COOKIE,
1181
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1182
-						? $_SERVER['REQUEST_METHOD']
1183
-						: null,
1184
-				],
1185
-				$c->getSecureRandom(),
1186
-				$c->getConfig()
1187
-			);
1188
-
1189
-			return new CryptoWrapper(
1190
-				$c->getConfig(),
1191
-				$c->getCrypto(),
1192
-				$c->getSecureRandom(),
1193
-				$request
1194
-			);
1195
-		});
1196
-		$this->registerService(CsrfTokenManager::class, function (Server $c) {
1197
-			$tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
1198
-
1199
-			return new CsrfTokenManager(
1200
-				$tokenGenerator,
1201
-				$c->query(SessionStorage::class)
1202
-			);
1203
-		});
1204
-		$this->registerDeprecatedAlias('CsrfTokenManager', CsrfTokenManager::class);
1205
-		$this->registerService(SessionStorage::class, function (Server $c) {
1206
-			return new SessionStorage($c->getSession());
1207
-		});
1208
-		$this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class);
1209
-		$this->registerDeprecatedAlias('ContentSecurityPolicyManager', ContentSecurityPolicyManager::class);
1210
-
1211
-		$this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) {
1212
-			return new ContentSecurityPolicyNonceManager(
1213
-				$c->getCsrfTokenManager(),
1214
-				$c->getRequest()
1215
-			);
1216
-		});
1217
-
1218
-		$this->registerService(\OCP\Share\IManager::class, function (Server $c) {
1219
-			$config = $c->getConfig();
1220
-			$factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
1221
-			/** @var \OCP\Share\IProviderFactory $factory */
1222
-			$factory = new $factoryClass($this);
1223
-
1224
-			$manager = new \OC\Share20\Manager(
1225
-				$c->getLogger(),
1226
-				$c->getConfig(),
1227
-				$c->getSecureRandom(),
1228
-				$c->getHasher(),
1229
-				$c->getMountManager(),
1230
-				$c->getGroupManager(),
1231
-				$c->getL10N('lib'),
1232
-				$c->getL10NFactory(),
1233
-				$factory,
1234
-				$c->getUserManager(),
1235
-				$c->getLazyRootFolder(),
1236
-				$c->getEventDispatcher(),
1237
-				$c->getMailer(),
1238
-				$c->getURLGenerator(),
1239
-				$c->getThemingDefaults(),
1240
-				$c->query(IEventDispatcher::class)
1241
-			);
1242
-
1243
-			return $manager;
1244
-		});
1245
-		$this->registerDeprecatedAlias('ShareManager', \OCP\Share\IManager::class);
1246
-
1247
-		$this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) {
1248
-			$instance = new Collaboration\Collaborators\Search($c);
1249
-
1250
-			// register default plugins
1251
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
1252
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
1253
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
1254
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
1255
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]);
1256
-
1257
-			return $instance;
1258
-		});
1259
-		$this->registerDeprecatedAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class);
1260
-		$this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class);
1261
-
1262
-		$this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
1263
-
1264
-		$this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class);
1265
-		$this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class);
1266
-
1267
-		$this->registerService('SettingsManager', function (Server $c) {
1268
-			$manager = new \OC\Settings\Manager(
1269
-				$c->getLogger(),
1270
-				$c->getL10NFactory(),
1271
-				$c->getURLGenerator(),
1272
-				$c
1273
-			);
1274
-			return $manager;
1275
-		});
1276
-		$this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) {
1277
-			return new \OC\Files\AppData\Factory(
1278
-				$c->getRootFolder(),
1279
-				$c->getSystemConfig()
1280
-			);
1281
-		});
1282
-
1283
-		$this->registerService('LockdownManager', function (Server $c) {
1284
-			return new LockdownManager(function () use ($c) {
1285
-				return $c->getSession();
1286
-			});
1287
-		});
1288
-
1289
-		$this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) {
1290
-			return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService());
1291
-		});
1292
-
1293
-		$this->registerService(ICloudIdManager::class, function (Server $c) {
1294
-			return new CloudIdManager();
1295
-		});
1296
-
1297
-		$this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class);
1298
-
1299
-		$this->registerService(ICloudFederationProviderManager::class, function (Server $c) {
1300
-			return new CloudFederationProviderManager($c->getAppManager(), $c->getHTTPClientService(), $c->getCloudIdManager(), $c->getLogger());
1301
-		});
1302
-
1303
-		$this->registerService(ICloudFederationFactory::class, function (Server $c) {
1304
-			return new CloudFederationFactory();
1305
-		});
1306
-
1307
-		$this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1308
-		$this->registerDeprecatedAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
1309
-
1310
-		$this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1311
-		$this->registerDeprecatedAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1312
-
1313
-		$this->registerService(Defaults::class, function (Server $c) {
1314
-			return new Defaults(
1315
-				$c->getThemingDefaults()
1316
-			);
1317
-		});
1318
-		$this->registerDeprecatedAlias('Defaults', \OCP\Defaults::class);
1319
-
1320
-		$this->registerService(\OCP\ISession::class, function (SimpleContainer $c) {
1321
-			return $c->query(\OCP\IUserSession::class)->getSession();
1322
-		});
1323
-
1324
-		$this->registerService(IShareHelper::class, function (Server $c) {
1325
-			return new ShareHelper(
1326
-				$c->query(\OCP\Share\IManager::class)
1327
-			);
1328
-		});
1329
-
1330
-		$this->registerService(Installer::class, function (Server $c) {
1331
-			return new Installer(
1332
-				$c->getAppFetcher(),
1333
-				$c->getHTTPClientService(),
1334
-				$c->getTempManager(),
1335
-				$c->getLogger(),
1336
-				$c->getConfig(),
1337
-				\OC::$CLI
1338
-			);
1339
-		});
1340
-
1341
-		$this->registerService(IApiFactory::class, function (Server $c) {
1342
-			return new ApiFactory($c->getHTTPClientService());
1343
-		});
1344
-
1345
-		$this->registerService(IInstanceFactory::class, function (Server $c) {
1346
-			$memcacheFactory = $c->getMemCacheFactory();
1347
-			return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService());
1348
-		});
1349
-
1350
-		$this->registerService(IContactsStore::class, function (Server $c) {
1351
-			return new ContactsStore(
1352
-				$c->getContactsManager(),
1353
-				$c->getConfig(),
1354
-				$c->getUserManager(),
1355
-				$c->getGroupManager()
1356
-			);
1357
-		});
1358
-		$this->registerAlias(IContactsStore::class, ContactsStore::class);
1359
-		$this->registerAlias(IAccountManager::class, AccountManager::class);
1360
-
1361
-		$this->registerService(IStorageFactory::class, function () {
1362
-			return new StorageFactory();
1363
-		});
1364
-
1365
-		$this->registerAlias(IDashboardManager::class, DashboardManager::class);
1366
-		$this->registerAlias(\OCP\Dashboard\IManager::class, \OC\Dashboard\Manager::class);
1367
-		$this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class);
1368
-
1369
-		$this->registerAlias(ISubAdmin::class, SubAdmin::class);
1370
-
1371
-		$this->registerAlias(IInitialStateService::class, InitialStateService::class);
1372
-
1373
-		$this->connectDispatcher();
1374
-	}
1375
-
1376
-	public function boot() {
1377
-		/** @var HookConnector $hookConnector */
1378
-		$hookConnector = $this->query(HookConnector::class);
1379
-		$hookConnector->viewToNode();
1380
-	}
1381
-
1382
-	/**
1383
-	 * @return \OCP\Calendar\IManager
1384
-	 * @deprecated
1385
-	 */
1386
-	public function getCalendarManager() {
1387
-		return $this->query(\OC\Calendar\Manager::class);
1388
-	}
1389
-
1390
-	/**
1391
-	 * @return \OCP\Calendar\Resource\IManager
1392
-	 * @deprecated
1393
-	 */
1394
-	public function getCalendarResourceBackendManager() {
1395
-		return $this->query(\OC\Calendar\Resource\Manager::class);
1396
-	}
1397
-
1398
-	/**
1399
-	 * @return \OCP\Calendar\Room\IManager
1400
-	 * @deprecated
1401
-	 */
1402
-	public function getCalendarRoomBackendManager() {
1403
-		return $this->query(\OC\Calendar\Room\Manager::class);
1404
-	}
1405
-
1406
-	private function connectDispatcher() {
1407
-		$dispatcher = $this->getEventDispatcher();
1408
-
1409
-		// Delete avatar on user deletion
1410
-		$dispatcher->addListener('OCP\IUser::preDelete', function (GenericEvent $e) {
1411
-			$logger = $this->getLogger();
1412
-			$manager = $this->getAvatarManager();
1413
-			/** @var IUser $user */
1414
-			$user = $e->getSubject();
1415
-
1416
-			try {
1417
-				$avatar = $manager->getAvatar($user->getUID());
1418
-				$avatar->remove();
1419
-			} catch (NotFoundException $e) {
1420
-				// no avatar to remove
1421
-			} catch (\Exception $e) {
1422
-				// Ignore exceptions
1423
-				$logger->info('Could not cleanup avatar of ' . $user->getUID());
1424
-			}
1425
-		});
1426
-
1427
-		$dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) {
1428
-			$manager = $this->getAvatarManager();
1429
-			/** @var IUser $user */
1430
-			$user = $e->getSubject();
1431
-			$feature = $e->getArgument('feature');
1432
-			$oldValue = $e->getArgument('oldValue');
1433
-			$value = $e->getArgument('value');
1434
-
1435
-			// We only change the avatar on display name changes
1436
-			if ($feature !== 'displayName') {
1437
-				return;
1438
-			}
1439
-
1440
-			try {
1441
-				$avatar = $manager->getAvatar($user->getUID());
1442
-				$avatar->userChanged($feature, $oldValue, $value);
1443
-			} catch (NotFoundException $e) {
1444
-				// no avatar to remove
1445
-			}
1446
-		});
1447
-
1448
-		/** @var IEventDispatcher $eventDispatched */
1449
-		$eventDispatched = $this->query(IEventDispatcher::class);
1450
-		$eventDispatched->addServiceListener(LoginFailed::class, LoginFailedListener::class);
1451
-	}
1452
-
1453
-	/**
1454
-	 * @return \OCP\Contacts\IManager
1455
-	 * @deprecated
1456
-	 */
1457
-	public function getContactsManager() {
1458
-		return $this->query(\OCP\Contacts\IManager::class);
1459
-	}
1460
-
1461
-	/**
1462
-	 * @return \OC\Encryption\Manager
1463
-	 * @deprecated
1464
-	 */
1465
-	public function getEncryptionManager() {
1466
-		return $this->query(\OCP\Encryption\IManager::class);
1467
-	}
1468
-
1469
-	/**
1470
-	 * @return \OC\Encryption\File
1471
-	 * @deprecated
1472
-	 */
1473
-	public function getEncryptionFilesHelper() {
1474
-		return $this->query('EncryptionFileHelper');
1475
-	}
1476
-
1477
-	/**
1478
-	 * @return \OCP\Encryption\Keys\IStorage
1479
-	 * @deprecated
1480
-	 */
1481
-	public function getEncryptionKeyStorage() {
1482
-		return $this->query('EncryptionKeyStorage');
1483
-	}
1484
-
1485
-	/**
1486
-	 * The current request object holding all information about the request
1487
-	 * currently being processed is returned from this method.
1488
-	 * In case the current execution was not initiated by a web request null is returned
1489
-	 *
1490
-	 * @return \OCP\IRequest
1491
-	 * @deprecated
1492
-	 */
1493
-	public function getRequest() {
1494
-		return $this->query(IRequest::class);
1495
-	}
1496
-
1497
-	/**
1498
-	 * Returns the preview manager which can create preview images for a given file
1499
-	 *
1500
-	 * @return IPreview
1501
-	 * @deprecated
1502
-	 */
1503
-	public function getPreviewManager() {
1504
-		return $this->query(IPreview::class);
1505
-	}
1506
-
1507
-	/**
1508
-	 * Returns the tag manager which can get and set tags for different object types
1509
-	 *
1510
-	 * @see \OCP\ITagManager::load()
1511
-	 * @return ITagManager
1512
-	 * @deprecated
1513
-	 */
1514
-	public function getTagManager() {
1515
-		return $this->query(ITagManager::class);
1516
-	}
1517
-
1518
-	/**
1519
-	 * Returns the system-tag manager
1520
-	 *
1521
-	 * @return ISystemTagManager
1522
-	 *
1523
-	 * @since 9.0.0
1524
-	 * @deprecated
1525
-	 */
1526
-	public function getSystemTagManager() {
1527
-		return $this->query(ISystemTagManager::class);
1528
-	}
1529
-
1530
-	/**
1531
-	 * Returns the system-tag object mapper
1532
-	 *
1533
-	 * @return ISystemTagObjectMapper
1534
-	 *
1535
-	 * @since 9.0.0
1536
-	 * @deprecated
1537
-	 */
1538
-	public function getSystemTagObjectMapper() {
1539
-		return $this->query(ISystemTagObjectMapper::class);
1540
-	}
1541
-
1542
-	/**
1543
-	 * Returns the avatar manager, used for avatar functionality
1544
-	 *
1545
-	 * @return IAvatarManager
1546
-	 * @deprecated
1547
-	 */
1548
-	public function getAvatarManager() {
1549
-		return $this->query(IAvatarManager::class);
1550
-	}
1551
-
1552
-	/**
1553
-	 * Returns the root folder of ownCloud's data directory
1554
-	 *
1555
-	 * @return IRootFolder
1556
-	 * @deprecated
1557
-	 */
1558
-	public function getRootFolder() {
1559
-		return $this->query(IRootFolder::class);
1560
-	}
1561
-
1562
-	/**
1563
-	 * Returns the root folder of ownCloud's data directory
1564
-	 * This is the lazy variant so this gets only initialized once it
1565
-	 * is actually used.
1566
-	 *
1567
-	 * @return IRootFolder
1568
-	 */
1569
-	public function getLazyRootFolder() {
1570
-		return $this->query(IRootFolder::class);
1571
-	}
1572
-
1573
-	/**
1574
-	 * Returns a view to ownCloud's files folder
1575
-	 *
1576
-	 * @param string $userId user ID
1577
-	 * @return \OCP\Files\Folder|null
1578
-	 * @deprecated
1579
-	 */
1580
-	public function getUserFolder($userId = null) {
1581
-		if ($userId === null) {
1582
-			$user = $this->getUserSession()->getUser();
1583
-			if (!$user) {
1584
-				return null;
1585
-			}
1586
-			$userId = $user->getUID();
1587
-		}
1588
-		$root = $this->getRootFolder();
1589
-		return $root->getUserFolder($userId);
1590
-	}
1591
-
1592
-	/**
1593
-	 * @return \OC\User\Manager
1594
-	 * @deprecated
1595
-	 */
1596
-	public function getUserManager() {
1597
-		return $this->query(IUserManager::class);
1598
-	}
1599
-
1600
-	/**
1601
-	 * @return \OC\Group\Manager
1602
-	 * @deprecated
1603
-	 */
1604
-	public function getGroupManager() {
1605
-		return $this->query(IGroupManager::class);
1606
-	}
1607
-
1608
-	/**
1609
-	 * @return \OC\User\Session
1610
-	 * @deprecated
1611
-	 */
1612
-	public function getUserSession() {
1613
-		return $this->query(IUserSession::class);
1614
-	}
1615
-
1616
-	/**
1617
-	 * @return \OCP\ISession
1618
-	 * @deprecated
1619
-	 */
1620
-	public function getSession() {
1621
-		return $this->getUserSession()->getSession();
1622
-	}
1623
-
1624
-	/**
1625
-	 * @param \OCP\ISession $session
1626
-	 */
1627
-	public function setSession(\OCP\ISession $session) {
1628
-		$this->query(SessionStorage::class)->setSession($session);
1629
-		$this->getUserSession()->setSession($session);
1630
-		$this->query(Store::class)->setSession($session);
1631
-	}
1632
-
1633
-	/**
1634
-	 * @return \OC\Authentication\TwoFactorAuth\Manager
1635
-	 * @deprecated
1636
-	 */
1637
-	public function getTwoFactorAuthManager() {
1638
-		return $this->query(\OC\Authentication\TwoFactorAuth\Manager::class);
1639
-	}
1640
-
1641
-	/**
1642
-	 * @return \OC\NavigationManager
1643
-	 * @deprecated
1644
-	 */
1645
-	public function getNavigationManager() {
1646
-		return $this->query(INavigationManager::class);
1647
-	}
1648
-
1649
-	/**
1650
-	 * @return \OCP\IConfig
1651
-	 * @deprecated
1652
-	 */
1653
-	public function getConfig() {
1654
-		return $this->query(AllConfig::class);
1655
-	}
1656
-
1657
-	/**
1658
-	 * @return \OC\SystemConfig
1659
-	 * @deprecated
1660
-	 */
1661
-	public function getSystemConfig() {
1662
-		return $this->query(SystemConfig::class);
1663
-	}
1664
-
1665
-	/**
1666
-	 * Returns the app config manager
1667
-	 *
1668
-	 * @return IAppConfig
1669
-	 * @deprecated
1670
-	 */
1671
-	public function getAppConfig() {
1672
-		return $this->query(IAppConfig::class);
1673
-	}
1674
-
1675
-	/**
1676
-	 * @return IFactory
1677
-	 * @deprecated
1678
-	 */
1679
-	public function getL10NFactory() {
1680
-		return $this->query(IFactory::class);
1681
-	}
1682
-
1683
-	/**
1684
-	 * get an L10N instance
1685
-	 *
1686
-	 * @param string $app appid
1687
-	 * @param string $lang
1688
-	 * @return IL10N
1689
-	 * @deprecated
1690
-	 */
1691
-	public function getL10N($app, $lang = null) {
1692
-		return $this->getL10NFactory()->get($app, $lang);
1693
-	}
1694
-
1695
-	/**
1696
-	 * @return IURLGenerator
1697
-	 * @deprecated
1698
-	 */
1699
-	public function getURLGenerator() {
1700
-		return $this->query(IURLGenerator::class);
1701
-	}
1702
-
1703
-	/**
1704
-	 * @return AppFetcher
1705
-	 * @deprecated
1706
-	 */
1707
-	public function getAppFetcher() {
1708
-		return $this->query(AppFetcher::class);
1709
-	}
1710
-
1711
-	/**
1712
-	 * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1713
-	 * getMemCacheFactory() instead.
1714
-	 *
1715
-	 * @return ICache
1716
-	 * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1717
-	 */
1718
-	public function getCache() {
1719
-		return $this->query(ICache::class);
1720
-	}
1721
-
1722
-	/**
1723
-	 * Returns an \OCP\CacheFactory instance
1724
-	 *
1725
-	 * @return \OCP\ICacheFactory
1726
-	 * @deprecated
1727
-	 */
1728
-	public function getMemCacheFactory() {
1729
-		return $this->query(Factory::class);
1730
-	}
1731
-
1732
-	/**
1733
-	 * Returns an \OC\RedisFactory instance
1734
-	 *
1735
-	 * @return \OC\RedisFactory
1736
-	 * @deprecated
1737
-	 */
1738
-	public function getGetRedisFactory() {
1739
-		return $this->query('RedisFactory');
1740
-	}
1741
-
1742
-
1743
-	/**
1744
-	 * Returns the current session
1745
-	 *
1746
-	 * @return \OCP\IDBConnection
1747
-	 * @deprecated
1748
-	 */
1749
-	public function getDatabaseConnection() {
1750
-		return $this->query(IDBConnection::class);
1751
-	}
1752
-
1753
-	/**
1754
-	 * Returns the activity manager
1755
-	 *
1756
-	 * @return \OCP\Activity\IManager
1757
-	 * @deprecated
1758
-	 */
1759
-	public function getActivityManager() {
1760
-		return $this->query(\OCP\Activity\IManager::class);
1761
-	}
1762
-
1763
-	/**
1764
-	 * Returns an job list for controlling background jobs
1765
-	 *
1766
-	 * @return IJobList
1767
-	 * @deprecated
1768
-	 */
1769
-	public function getJobList() {
1770
-		return $this->query(IJobList::class);
1771
-	}
1772
-
1773
-	/**
1774
-	 * Returns a logger instance
1775
-	 *
1776
-	 * @return ILogger
1777
-	 * @deprecated
1778
-	 */
1779
-	public function getLogger() {
1780
-		return $this->query(ILogger::class);
1781
-	}
1782
-
1783
-	/**
1784
-	 * @return ILogFactory
1785
-	 * @throws \OCP\AppFramework\QueryException
1786
-	 * @deprecated
1787
-	 */
1788
-	public function getLogFactory() {
1789
-		return $this->query(ILogFactory::class);
1790
-	}
1791
-
1792
-	/**
1793
-	 * Returns a router for generating and matching urls
1794
-	 *
1795
-	 * @return IRouter
1796
-	 * @deprecated
1797
-	 */
1798
-	public function getRouter() {
1799
-		return $this->query(IRouter::class);
1800
-	}
1801
-
1802
-	/**
1803
-	 * Returns a search instance
1804
-	 *
1805
-	 * @return ISearch
1806
-	 * @deprecated
1807
-	 */
1808
-	public function getSearch() {
1809
-		return $this->query(ISearch::class);
1810
-	}
1811
-
1812
-	/**
1813
-	 * Returns a SecureRandom instance
1814
-	 *
1815
-	 * @return \OCP\Security\ISecureRandom
1816
-	 * @deprecated
1817
-	 */
1818
-	public function getSecureRandom() {
1819
-		return $this->query(ISecureRandom::class);
1820
-	}
1821
-
1822
-	/**
1823
-	 * Returns a Crypto instance
1824
-	 *
1825
-	 * @return ICrypto
1826
-	 * @deprecated
1827
-	 */
1828
-	public function getCrypto() {
1829
-		return $this->query(ICrypto::class);
1830
-	}
1831
-
1832
-	/**
1833
-	 * Returns a Hasher instance
1834
-	 *
1835
-	 * @return IHasher
1836
-	 * @deprecated
1837
-	 */
1838
-	public function getHasher() {
1839
-		return $this->query(IHasher::class);
1840
-	}
1841
-
1842
-	/**
1843
-	 * Returns a CredentialsManager instance
1844
-	 *
1845
-	 * @return ICredentialsManager
1846
-	 * @deprecated
1847
-	 */
1848
-	public function getCredentialsManager() {
1849
-		return $this->query(ICredentialsManager::class);
1850
-	}
1851
-
1852
-	/**
1853
-	 * Get the certificate manager for the user
1854
-	 *
1855
-	 * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
1856
-	 * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in
1857
-	 * @deprecated
1858
-	 */
1859
-	public function getCertificateManager($userId = '') {
1860
-		if ($userId === '') {
1861
-			$userSession = $this->getUserSession();
1862
-			$user = $userSession->getUser();
1863
-			if (is_null($user)) {
1864
-				return null;
1865
-			}
1866
-			$userId = $user->getUID();
1867
-		}
1868
-		return new CertificateManager(
1869
-			$userId,
1870
-			new View(),
1871
-			$this->getConfig(),
1872
-			$this->getLogger(),
1873
-			$this->getSecureRandom()
1874
-		);
1875
-	}
1876
-
1877
-	/**
1878
-	 * Returns an instance of the HTTP client service
1879
-	 *
1880
-	 * @return IClientService
1881
-	 * @deprecated
1882
-	 */
1883
-	public function getHTTPClientService() {
1884
-		return $this->query(IClientService::class);
1885
-	}
1886
-
1887
-	/**
1888
-	 * Create a new event source
1889
-	 *
1890
-	 * @return \OCP\IEventSource
1891
-	 * @deprecated
1892
-	 */
1893
-	public function createEventSource() {
1894
-		return new \OC_EventSource();
1895
-	}
1896
-
1897
-	/**
1898
-	 * Get the active event logger
1899
-	 *
1900
-	 * The returned logger only logs data when debug mode is enabled
1901
-	 *
1902
-	 * @return IEventLogger
1903
-	 * @deprecated
1904
-	 */
1905
-	public function getEventLogger() {
1906
-		return $this->query(IEventLogger::class);
1907
-	}
1908
-
1909
-	/**
1910
-	 * Get the active query logger
1911
-	 *
1912
-	 * The returned logger only logs data when debug mode is enabled
1913
-	 *
1914
-	 * @return IQueryLogger
1915
-	 * @deprecated
1916
-	 */
1917
-	public function getQueryLogger() {
1918
-		return $this->query(IQueryLogger::class);
1919
-	}
1920
-
1921
-	/**
1922
-	 * Get the manager for temporary files and folders
1923
-	 *
1924
-	 * @return \OCP\ITempManager
1925
-	 * @deprecated
1926
-	 */
1927
-	public function getTempManager() {
1928
-		return $this->query(ITempManager::class);
1929
-	}
1930
-
1931
-	/**
1932
-	 * Get the app manager
1933
-	 *
1934
-	 * @return \OCP\App\IAppManager
1935
-	 * @deprecated
1936
-	 */
1937
-	public function getAppManager() {
1938
-		return $this->query(IAppManager::class);
1939
-	}
1940
-
1941
-	/**
1942
-	 * Creates a new mailer
1943
-	 *
1944
-	 * @return IMailer
1945
-	 * @deprecated
1946
-	 */
1947
-	public function getMailer() {
1948
-		return $this->query(IMailer::class);
1949
-	}
1950
-
1951
-	/**
1952
-	 * Get the webroot
1953
-	 *
1954
-	 * @return string
1955
-	 * @deprecated
1956
-	 */
1957
-	public function getWebRoot() {
1958
-		return $this->webRoot;
1959
-	}
1960
-
1961
-	/**
1962
-	 * @return \OC\OCSClient
1963
-	 * @deprecated
1964
-	 */
1965
-	public function getOcsClient() {
1966
-		return $this->query('OcsClient');
1967
-	}
1968
-
1969
-	/**
1970
-	 * @return IDateTimeZone
1971
-	 * @deprecated
1972
-	 */
1973
-	public function getDateTimeZone() {
1974
-		return $this->query(IDateTimeZone::class);
1975
-	}
1976
-
1977
-	/**
1978
-	 * @return IDateTimeFormatter
1979
-	 * @deprecated
1980
-	 */
1981
-	public function getDateTimeFormatter() {
1982
-		return $this->query(IDateTimeFormatter::class);
1983
-	}
1984
-
1985
-	/**
1986
-	 * @return IMountProviderCollection
1987
-	 * @deprecated
1988
-	 */
1989
-	public function getMountProviderCollection() {
1990
-		return $this->query(IMountProviderCollection::class);
1991
-	}
1992
-
1993
-	/**
1994
-	 * Get the IniWrapper
1995
-	 *
1996
-	 * @return IniGetWrapper
1997
-	 * @deprecated
1998
-	 */
1999
-	public function getIniWrapper() {
2000
-		return $this->query('IniWrapper');
2001
-	}
2002
-
2003
-	/**
2004
-	 * @return \OCP\Command\IBus
2005
-	 * @deprecated
2006
-	 */
2007
-	public function getCommandBus() {
2008
-		return $this->query('AsyncCommandBus');
2009
-	}
2010
-
2011
-	/**
2012
-	 * Get the trusted domain helper
2013
-	 *
2014
-	 * @return TrustedDomainHelper
2015
-	 * @deprecated
2016
-	 */
2017
-	public function getTrustedDomainHelper() {
2018
-		return $this->query('TrustedDomainHelper');
2019
-	}
2020
-
2021
-	/**
2022
-	 * Get the locking provider
2023
-	 *
2024
-	 * @return ILockingProvider
2025
-	 * @since 8.1.0
2026
-	 * @deprecated
2027
-	 */
2028
-	public function getLockingProvider() {
2029
-		return $this->query(ILockingProvider::class);
2030
-	}
2031
-
2032
-	/**
2033
-	 * @return IMountManager
2034
-	 * @deprecated
2035
-	 **/
2036
-	public function getMountManager() {
2037
-		return $this->query(IMountManager::class);
2038
-	}
2039
-
2040
-	/**
2041
-	 * @return IUserMountCache
2042
-	 * @deprecated
2043
-	 */
2044
-	public function getUserMountCache() {
2045
-		return $this->query(IUserMountCache::class);
2046
-	}
2047
-
2048
-	/**
2049
-	 * Get the MimeTypeDetector
2050
-	 *
2051
-	 * @return IMimeTypeDetector
2052
-	 * @deprecated
2053
-	 */
2054
-	public function getMimeTypeDetector() {
2055
-		return $this->query(IMimeTypeDetector::class);
2056
-	}
2057
-
2058
-	/**
2059
-	 * Get the MimeTypeLoader
2060
-	 *
2061
-	 * @return IMimeTypeLoader
2062
-	 * @deprecated
2063
-	 */
2064
-	public function getMimeTypeLoader() {
2065
-		return $this->query(IMimeTypeLoader::class);
2066
-	}
2067
-
2068
-	/**
2069
-	 * Get the manager of all the capabilities
2070
-	 *
2071
-	 * @return CapabilitiesManager
2072
-	 * @deprecated
2073
-	 */
2074
-	public function getCapabilitiesManager() {
2075
-		return $this->query(CapabilitiesManager::class);
2076
-	}
2077
-
2078
-	/**
2079
-	 * Get the EventDispatcher
2080
-	 *
2081
-	 * @return EventDispatcherInterface
2082
-	 * @since 8.2.0
2083
-	 * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher
2084
-	 */
2085
-	public function getEventDispatcher() {
2086
-		return $this->query(\OC\EventDispatcher\SymfonyAdapter::class);
2087
-	}
2088
-
2089
-	/**
2090
-	 * Get the Notification Manager
2091
-	 *
2092
-	 * @return \OCP\Notification\IManager
2093
-	 * @since 8.2.0
2094
-	 * @deprecated
2095
-	 */
2096
-	public function getNotificationManager() {
2097
-		return $this->query(\OCP\Notification\IManager::class);
2098
-	}
2099
-
2100
-	/**
2101
-	 * @return ICommentsManager
2102
-	 * @deprecated
2103
-	 */
2104
-	public function getCommentsManager() {
2105
-		return $this->query(ICommentsManager::class);
2106
-	}
2107
-
2108
-	/**
2109
-	 * @return \OCA\Theming\ThemingDefaults
2110
-	 * @deprecated
2111
-	 */
2112
-	public function getThemingDefaults() {
2113
-		return $this->query('ThemingDefaults');
2114
-	}
2115
-
2116
-	/**
2117
-	 * @return \OC\IntegrityCheck\Checker
2118
-	 * @deprecated
2119
-	 */
2120
-	public function getIntegrityCodeChecker() {
2121
-		return $this->query('IntegrityCodeChecker');
2122
-	}
2123
-
2124
-	/**
2125
-	 * @return \OC\Session\CryptoWrapper
2126
-	 * @deprecated
2127
-	 */
2128
-	public function getSessionCryptoWrapper() {
2129
-		return $this->query('CryptoWrapper');
2130
-	}
2131
-
2132
-	/**
2133
-	 * @return CsrfTokenManager
2134
-	 * @deprecated
2135
-	 */
2136
-	public function getCsrfTokenManager() {
2137
-		return $this->query(CsrfTokenManager::class);
2138
-	}
2139
-
2140
-	/**
2141
-	 * @return Throttler
2142
-	 * @deprecated
2143
-	 */
2144
-	public function getBruteForceThrottler() {
2145
-		return $this->query(Throttler::class);
2146
-	}
2147
-
2148
-	/**
2149
-	 * @return IContentSecurityPolicyManager
2150
-	 * @deprecated
2151
-	 */
2152
-	public function getContentSecurityPolicyManager() {
2153
-		return $this->query(ContentSecurityPolicyManager::class);
2154
-	}
2155
-
2156
-	/**
2157
-	 * @return ContentSecurityPolicyNonceManager
2158
-	 * @deprecated
2159
-	 */
2160
-	public function getContentSecurityPolicyNonceManager() {
2161
-		return $this->query('ContentSecurityPolicyNonceManager');
2162
-	}
2163
-
2164
-	/**
2165
-	 * Not a public API as of 8.2, wait for 9.0
2166
-	 *
2167
-	 * @return \OCA\Files_External\Service\BackendService
2168
-	 * @deprecated
2169
-	 */
2170
-	public function getStoragesBackendService() {
2171
-		return $this->query(BackendService::class);
2172
-	}
2173
-
2174
-	/**
2175
-	 * Not a public API as of 8.2, wait for 9.0
2176
-	 *
2177
-	 * @return \OCA\Files_External\Service\GlobalStoragesService
2178
-	 * @deprecated
2179
-	 */
2180
-	public function getGlobalStoragesService() {
2181
-		return $this->query(GlobalStoragesService::class);
2182
-	}
2183
-
2184
-	/**
2185
-	 * Not a public API as of 8.2, wait for 9.0
2186
-	 *
2187
-	 * @return \OCA\Files_External\Service\UserGlobalStoragesService
2188
-	 * @deprecated
2189
-	 */
2190
-	public function getUserGlobalStoragesService() {
2191
-		return $this->query(UserGlobalStoragesService::class);
2192
-	}
2193
-
2194
-	/**
2195
-	 * Not a public API as of 8.2, wait for 9.0
2196
-	 *
2197
-	 * @return \OCA\Files_External\Service\UserStoragesService
2198
-	 * @deprecated
2199
-	 */
2200
-	public function getUserStoragesService() {
2201
-		return $this->query(UserStoragesService::class);
2202
-	}
2203
-
2204
-	/**
2205
-	 * @return \OCP\Share\IManager
2206
-	 * @deprecated
2207
-	 */
2208
-	public function getShareManager() {
2209
-		return $this->query(\OCP\Share\IManager::class);
2210
-	}
2211
-
2212
-	/**
2213
-	 * @return \OCP\Collaboration\Collaborators\ISearch
2214
-	 * @deprecated
2215
-	 */
2216
-	public function getCollaboratorSearch() {
2217
-		return $this->query(\OCP\Collaboration\Collaborators\ISearch::class);
2218
-	}
2219
-
2220
-	/**
2221
-	 * @return \OCP\Collaboration\AutoComplete\IManager
2222
-	 * @deprecated
2223
-	 */
2224
-	public function getAutoCompleteManager() {
2225
-		return $this->query(IManager::class);
2226
-	}
2227
-
2228
-	/**
2229
-	 * Returns the LDAP Provider
2230
-	 *
2231
-	 * @return \OCP\LDAP\ILDAPProvider
2232
-	 * @deprecated
2233
-	 */
2234
-	public function getLDAPProvider() {
2235
-		return $this->query('LDAPProvider');
2236
-	}
2237
-
2238
-	/**
2239
-	 * @return \OCP\Settings\IManager
2240
-	 * @deprecated
2241
-	 */
2242
-	public function getSettingsManager() {
2243
-		return $this->query('SettingsManager');
2244
-	}
2245
-
2246
-	/**
2247
-	 * @return \OCP\Files\IAppData
2248
-	 * @deprecated
2249
-	 */
2250
-	public function getAppDataDir($app) {
2251
-		/** @var \OC\Files\AppData\Factory $factory */
2252
-		$factory = $this->query(\OC\Files\AppData\Factory::class);
2253
-		return $factory->get($app);
2254
-	}
2255
-
2256
-	/**
2257
-	 * @return \OCP\Lockdown\ILockdownManager
2258
-	 * @deprecated
2259
-	 */
2260
-	public function getLockdownManager() {
2261
-		return $this->query('LockdownManager');
2262
-	}
2263
-
2264
-	/**
2265
-	 * @return \OCP\Federation\ICloudIdManager
2266
-	 * @deprecated
2267
-	 */
2268
-	public function getCloudIdManager() {
2269
-		return $this->query(ICloudIdManager::class);
2270
-	}
2271
-
2272
-	/**
2273
-	 * @return \OCP\GlobalScale\IConfig
2274
-	 * @deprecated
2275
-	 */
2276
-	public function getGlobalScaleConfig() {
2277
-		return $this->query(IConfig::class);
2278
-	}
2279
-
2280
-	/**
2281
-	 * @return \OCP\Federation\ICloudFederationProviderManager
2282
-	 * @deprecated
2283
-	 */
2284
-	public function getCloudFederationProviderManager() {
2285
-		return $this->query(ICloudFederationProviderManager::class);
2286
-	}
2287
-
2288
-	/**
2289
-	 * @return \OCP\Remote\Api\IApiFactory
2290
-	 * @deprecated
2291
-	 */
2292
-	public function getRemoteApiFactory() {
2293
-		return $this->query(IApiFactory::class);
2294
-	}
2295
-
2296
-	/**
2297
-	 * @return \OCP\Federation\ICloudFederationFactory
2298
-	 * @deprecated
2299
-	 */
2300
-	public function getCloudFederationFactory() {
2301
-		return $this->query(ICloudFederationFactory::class);
2302
-	}
2303
-
2304
-	/**
2305
-	 * @return \OCP\Remote\IInstanceFactory
2306
-	 * @deprecated
2307
-	 */
2308
-	public function getRemoteInstanceFactory() {
2309
-		return $this->query(IInstanceFactory::class);
2310
-	}
2311
-
2312
-	/**
2313
-	 * @return IStorageFactory
2314
-	 * @deprecated
2315
-	 */
2316
-	public function getStorageFactory() {
2317
-		return $this->query(IStorageFactory::class);
2318
-	}
2319
-
2320
-	/**
2321
-	 * Get the Preview GeneratorHelper
2322
-	 *
2323
-	 * @return GeneratorHelper
2324
-	 * @since 17.0.0
2325
-	 * @deprecated
2326
-	 */
2327
-	public function getGeneratorHelper() {
2328
-		return $this->query(\OC\Preview\GeneratorHelper::class);
2329
-	}
2330
-
2331
-	private function registerDeprecatedAlias(string $alias, string $target) {
2332
-		$this->registerService($alias, function (ContainerInterface $container) use ($target, $alias) {
2333
-			try {
2334
-				/** @var ILogger $logger */
2335
-				$logger = $container->get(ILogger::class);
2336
-				$logger->debug('The requested alias "' . $alias . '" is depreacted. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']);
2337
-			} catch (ContainerExceptionInterface $e) {
2338
-				// Could not get logger. Continue
2339
-			}
2340
-
2341
-			return $container->get($target);
2342
-		}, false);
2343
-	}
1124
+            $prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
1125
+            if (isset($prefixes['OCA\\Theming\\'])) {
1126
+                $classExists = true;
1127
+            } else {
1128
+                $classExists = false;
1129
+            }
1130
+
1131
+            if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
1132
+                return new ThemingDefaults(
1133
+                    $c->getConfig(),
1134
+                    $c->getL10N('theming'),
1135
+                    $c->getURLGenerator(),
1136
+                    $c->getMemCacheFactory(),
1137
+                    new Util($c->getConfig(), $this->getAppManager(), $c->getAppDataDir('theming')),
1138
+                    new ImageManager($c->getConfig(), $c->getAppDataDir('theming'), $c->getURLGenerator(), $this->getMemCacheFactory(), $this->getLogger()),
1139
+                    $c->getAppManager(),
1140
+                    $c->getNavigationManager()
1141
+                );
1142
+            }
1143
+            return new \OC_Defaults();
1144
+        });
1145
+        $this->registerService(SCSSCacher::class, function (Server $c) {
1146
+            return new SCSSCacher(
1147
+                $c->getLogger(),
1148
+                $c->query(\OC\Files\AppData\Factory::class),
1149
+                $c->getURLGenerator(),
1150
+                $c->getConfig(),
1151
+                $c->getThemingDefaults(),
1152
+                \OC::$SERVERROOT,
1153
+                $this->getMemCacheFactory(),
1154
+                $c->query(IconsCacher::class),
1155
+                new TimeFactory()
1156
+            );
1157
+        });
1158
+        $this->registerService(JSCombiner::class, function (Server $c) {
1159
+            return new JSCombiner(
1160
+                $c->getAppDataDir('js'),
1161
+                $c->getURLGenerator(),
1162
+                $this->getMemCacheFactory(),
1163
+                $c->getSystemConfig(),
1164
+                $c->getLogger()
1165
+            );
1166
+        });
1167
+        $this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class);
1168
+        $this->registerDeprecatedAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class);
1169
+        $this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class);
1170
+
1171
+        $this->registerService('CryptoWrapper', function (Server $c) {
1172
+            // FIXME: Instantiiated here due to cyclic dependency
1173
+            $request = new Request(
1174
+                [
1175
+                    'get' => $_GET,
1176
+                    'post' => $_POST,
1177
+                    'files' => $_FILES,
1178
+                    'server' => $_SERVER,
1179
+                    'env' => $_ENV,
1180
+                    'cookies' => $_COOKIE,
1181
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1182
+                        ? $_SERVER['REQUEST_METHOD']
1183
+                        : null,
1184
+                ],
1185
+                $c->getSecureRandom(),
1186
+                $c->getConfig()
1187
+            );
1188
+
1189
+            return new CryptoWrapper(
1190
+                $c->getConfig(),
1191
+                $c->getCrypto(),
1192
+                $c->getSecureRandom(),
1193
+                $request
1194
+            );
1195
+        });
1196
+        $this->registerService(CsrfTokenManager::class, function (Server $c) {
1197
+            $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
1198
+
1199
+            return new CsrfTokenManager(
1200
+                $tokenGenerator,
1201
+                $c->query(SessionStorage::class)
1202
+            );
1203
+        });
1204
+        $this->registerDeprecatedAlias('CsrfTokenManager', CsrfTokenManager::class);
1205
+        $this->registerService(SessionStorage::class, function (Server $c) {
1206
+            return new SessionStorage($c->getSession());
1207
+        });
1208
+        $this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class);
1209
+        $this->registerDeprecatedAlias('ContentSecurityPolicyManager', ContentSecurityPolicyManager::class);
1210
+
1211
+        $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) {
1212
+            return new ContentSecurityPolicyNonceManager(
1213
+                $c->getCsrfTokenManager(),
1214
+                $c->getRequest()
1215
+            );
1216
+        });
1217
+
1218
+        $this->registerService(\OCP\Share\IManager::class, function (Server $c) {
1219
+            $config = $c->getConfig();
1220
+            $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
1221
+            /** @var \OCP\Share\IProviderFactory $factory */
1222
+            $factory = new $factoryClass($this);
1223
+
1224
+            $manager = new \OC\Share20\Manager(
1225
+                $c->getLogger(),
1226
+                $c->getConfig(),
1227
+                $c->getSecureRandom(),
1228
+                $c->getHasher(),
1229
+                $c->getMountManager(),
1230
+                $c->getGroupManager(),
1231
+                $c->getL10N('lib'),
1232
+                $c->getL10NFactory(),
1233
+                $factory,
1234
+                $c->getUserManager(),
1235
+                $c->getLazyRootFolder(),
1236
+                $c->getEventDispatcher(),
1237
+                $c->getMailer(),
1238
+                $c->getURLGenerator(),
1239
+                $c->getThemingDefaults(),
1240
+                $c->query(IEventDispatcher::class)
1241
+            );
1242
+
1243
+            return $manager;
1244
+        });
1245
+        $this->registerDeprecatedAlias('ShareManager', \OCP\Share\IManager::class);
1246
+
1247
+        $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) {
1248
+            $instance = new Collaboration\Collaborators\Search($c);
1249
+
1250
+            // register default plugins
1251
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
1252
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
1253
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
1254
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
1255
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]);
1256
+
1257
+            return $instance;
1258
+        });
1259
+        $this->registerDeprecatedAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class);
1260
+        $this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class);
1261
+
1262
+        $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
1263
+
1264
+        $this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class);
1265
+        $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class);
1266
+
1267
+        $this->registerService('SettingsManager', function (Server $c) {
1268
+            $manager = new \OC\Settings\Manager(
1269
+                $c->getLogger(),
1270
+                $c->getL10NFactory(),
1271
+                $c->getURLGenerator(),
1272
+                $c
1273
+            );
1274
+            return $manager;
1275
+        });
1276
+        $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) {
1277
+            return new \OC\Files\AppData\Factory(
1278
+                $c->getRootFolder(),
1279
+                $c->getSystemConfig()
1280
+            );
1281
+        });
1282
+
1283
+        $this->registerService('LockdownManager', function (Server $c) {
1284
+            return new LockdownManager(function () use ($c) {
1285
+                return $c->getSession();
1286
+            });
1287
+        });
1288
+
1289
+        $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) {
1290
+            return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService());
1291
+        });
1292
+
1293
+        $this->registerService(ICloudIdManager::class, function (Server $c) {
1294
+            return new CloudIdManager();
1295
+        });
1296
+
1297
+        $this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class);
1298
+
1299
+        $this->registerService(ICloudFederationProviderManager::class, function (Server $c) {
1300
+            return new CloudFederationProviderManager($c->getAppManager(), $c->getHTTPClientService(), $c->getCloudIdManager(), $c->getLogger());
1301
+        });
1302
+
1303
+        $this->registerService(ICloudFederationFactory::class, function (Server $c) {
1304
+            return new CloudFederationFactory();
1305
+        });
1306
+
1307
+        $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1308
+        $this->registerDeprecatedAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
1309
+
1310
+        $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1311
+        $this->registerDeprecatedAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1312
+
1313
+        $this->registerService(Defaults::class, function (Server $c) {
1314
+            return new Defaults(
1315
+                $c->getThemingDefaults()
1316
+            );
1317
+        });
1318
+        $this->registerDeprecatedAlias('Defaults', \OCP\Defaults::class);
1319
+
1320
+        $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) {
1321
+            return $c->query(\OCP\IUserSession::class)->getSession();
1322
+        });
1323
+
1324
+        $this->registerService(IShareHelper::class, function (Server $c) {
1325
+            return new ShareHelper(
1326
+                $c->query(\OCP\Share\IManager::class)
1327
+            );
1328
+        });
1329
+
1330
+        $this->registerService(Installer::class, function (Server $c) {
1331
+            return new Installer(
1332
+                $c->getAppFetcher(),
1333
+                $c->getHTTPClientService(),
1334
+                $c->getTempManager(),
1335
+                $c->getLogger(),
1336
+                $c->getConfig(),
1337
+                \OC::$CLI
1338
+            );
1339
+        });
1340
+
1341
+        $this->registerService(IApiFactory::class, function (Server $c) {
1342
+            return new ApiFactory($c->getHTTPClientService());
1343
+        });
1344
+
1345
+        $this->registerService(IInstanceFactory::class, function (Server $c) {
1346
+            $memcacheFactory = $c->getMemCacheFactory();
1347
+            return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService());
1348
+        });
1349
+
1350
+        $this->registerService(IContactsStore::class, function (Server $c) {
1351
+            return new ContactsStore(
1352
+                $c->getContactsManager(),
1353
+                $c->getConfig(),
1354
+                $c->getUserManager(),
1355
+                $c->getGroupManager()
1356
+            );
1357
+        });
1358
+        $this->registerAlias(IContactsStore::class, ContactsStore::class);
1359
+        $this->registerAlias(IAccountManager::class, AccountManager::class);
1360
+
1361
+        $this->registerService(IStorageFactory::class, function () {
1362
+            return new StorageFactory();
1363
+        });
1364
+
1365
+        $this->registerAlias(IDashboardManager::class, DashboardManager::class);
1366
+        $this->registerAlias(\OCP\Dashboard\IManager::class, \OC\Dashboard\Manager::class);
1367
+        $this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class);
1368
+
1369
+        $this->registerAlias(ISubAdmin::class, SubAdmin::class);
1370
+
1371
+        $this->registerAlias(IInitialStateService::class, InitialStateService::class);
1372
+
1373
+        $this->connectDispatcher();
1374
+    }
1375
+
1376
+    public function boot() {
1377
+        /** @var HookConnector $hookConnector */
1378
+        $hookConnector = $this->query(HookConnector::class);
1379
+        $hookConnector->viewToNode();
1380
+    }
1381
+
1382
+    /**
1383
+     * @return \OCP\Calendar\IManager
1384
+     * @deprecated
1385
+     */
1386
+    public function getCalendarManager() {
1387
+        return $this->query(\OC\Calendar\Manager::class);
1388
+    }
1389
+
1390
+    /**
1391
+     * @return \OCP\Calendar\Resource\IManager
1392
+     * @deprecated
1393
+     */
1394
+    public function getCalendarResourceBackendManager() {
1395
+        return $this->query(\OC\Calendar\Resource\Manager::class);
1396
+    }
1397
+
1398
+    /**
1399
+     * @return \OCP\Calendar\Room\IManager
1400
+     * @deprecated
1401
+     */
1402
+    public function getCalendarRoomBackendManager() {
1403
+        return $this->query(\OC\Calendar\Room\Manager::class);
1404
+    }
1405
+
1406
+    private function connectDispatcher() {
1407
+        $dispatcher = $this->getEventDispatcher();
1408
+
1409
+        // Delete avatar on user deletion
1410
+        $dispatcher->addListener('OCP\IUser::preDelete', function (GenericEvent $e) {
1411
+            $logger = $this->getLogger();
1412
+            $manager = $this->getAvatarManager();
1413
+            /** @var IUser $user */
1414
+            $user = $e->getSubject();
1415
+
1416
+            try {
1417
+                $avatar = $manager->getAvatar($user->getUID());
1418
+                $avatar->remove();
1419
+            } catch (NotFoundException $e) {
1420
+                // no avatar to remove
1421
+            } catch (\Exception $e) {
1422
+                // Ignore exceptions
1423
+                $logger->info('Could not cleanup avatar of ' . $user->getUID());
1424
+            }
1425
+        });
1426
+
1427
+        $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) {
1428
+            $manager = $this->getAvatarManager();
1429
+            /** @var IUser $user */
1430
+            $user = $e->getSubject();
1431
+            $feature = $e->getArgument('feature');
1432
+            $oldValue = $e->getArgument('oldValue');
1433
+            $value = $e->getArgument('value');
1434
+
1435
+            // We only change the avatar on display name changes
1436
+            if ($feature !== 'displayName') {
1437
+                return;
1438
+            }
1439
+
1440
+            try {
1441
+                $avatar = $manager->getAvatar($user->getUID());
1442
+                $avatar->userChanged($feature, $oldValue, $value);
1443
+            } catch (NotFoundException $e) {
1444
+                // no avatar to remove
1445
+            }
1446
+        });
1447
+
1448
+        /** @var IEventDispatcher $eventDispatched */
1449
+        $eventDispatched = $this->query(IEventDispatcher::class);
1450
+        $eventDispatched->addServiceListener(LoginFailed::class, LoginFailedListener::class);
1451
+    }
1452
+
1453
+    /**
1454
+     * @return \OCP\Contacts\IManager
1455
+     * @deprecated
1456
+     */
1457
+    public function getContactsManager() {
1458
+        return $this->query(\OCP\Contacts\IManager::class);
1459
+    }
1460
+
1461
+    /**
1462
+     * @return \OC\Encryption\Manager
1463
+     * @deprecated
1464
+     */
1465
+    public function getEncryptionManager() {
1466
+        return $this->query(\OCP\Encryption\IManager::class);
1467
+    }
1468
+
1469
+    /**
1470
+     * @return \OC\Encryption\File
1471
+     * @deprecated
1472
+     */
1473
+    public function getEncryptionFilesHelper() {
1474
+        return $this->query('EncryptionFileHelper');
1475
+    }
1476
+
1477
+    /**
1478
+     * @return \OCP\Encryption\Keys\IStorage
1479
+     * @deprecated
1480
+     */
1481
+    public function getEncryptionKeyStorage() {
1482
+        return $this->query('EncryptionKeyStorage');
1483
+    }
1484
+
1485
+    /**
1486
+     * The current request object holding all information about the request
1487
+     * currently being processed is returned from this method.
1488
+     * In case the current execution was not initiated by a web request null is returned
1489
+     *
1490
+     * @return \OCP\IRequest
1491
+     * @deprecated
1492
+     */
1493
+    public function getRequest() {
1494
+        return $this->query(IRequest::class);
1495
+    }
1496
+
1497
+    /**
1498
+     * Returns the preview manager which can create preview images for a given file
1499
+     *
1500
+     * @return IPreview
1501
+     * @deprecated
1502
+     */
1503
+    public function getPreviewManager() {
1504
+        return $this->query(IPreview::class);
1505
+    }
1506
+
1507
+    /**
1508
+     * Returns the tag manager which can get and set tags for different object types
1509
+     *
1510
+     * @see \OCP\ITagManager::load()
1511
+     * @return ITagManager
1512
+     * @deprecated
1513
+     */
1514
+    public function getTagManager() {
1515
+        return $this->query(ITagManager::class);
1516
+    }
1517
+
1518
+    /**
1519
+     * Returns the system-tag manager
1520
+     *
1521
+     * @return ISystemTagManager
1522
+     *
1523
+     * @since 9.0.0
1524
+     * @deprecated
1525
+     */
1526
+    public function getSystemTagManager() {
1527
+        return $this->query(ISystemTagManager::class);
1528
+    }
1529
+
1530
+    /**
1531
+     * Returns the system-tag object mapper
1532
+     *
1533
+     * @return ISystemTagObjectMapper
1534
+     *
1535
+     * @since 9.0.0
1536
+     * @deprecated
1537
+     */
1538
+    public function getSystemTagObjectMapper() {
1539
+        return $this->query(ISystemTagObjectMapper::class);
1540
+    }
1541
+
1542
+    /**
1543
+     * Returns the avatar manager, used for avatar functionality
1544
+     *
1545
+     * @return IAvatarManager
1546
+     * @deprecated
1547
+     */
1548
+    public function getAvatarManager() {
1549
+        return $this->query(IAvatarManager::class);
1550
+    }
1551
+
1552
+    /**
1553
+     * Returns the root folder of ownCloud's data directory
1554
+     *
1555
+     * @return IRootFolder
1556
+     * @deprecated
1557
+     */
1558
+    public function getRootFolder() {
1559
+        return $this->query(IRootFolder::class);
1560
+    }
1561
+
1562
+    /**
1563
+     * Returns the root folder of ownCloud's data directory
1564
+     * This is the lazy variant so this gets only initialized once it
1565
+     * is actually used.
1566
+     *
1567
+     * @return IRootFolder
1568
+     */
1569
+    public function getLazyRootFolder() {
1570
+        return $this->query(IRootFolder::class);
1571
+    }
1572
+
1573
+    /**
1574
+     * Returns a view to ownCloud's files folder
1575
+     *
1576
+     * @param string $userId user ID
1577
+     * @return \OCP\Files\Folder|null
1578
+     * @deprecated
1579
+     */
1580
+    public function getUserFolder($userId = null) {
1581
+        if ($userId === null) {
1582
+            $user = $this->getUserSession()->getUser();
1583
+            if (!$user) {
1584
+                return null;
1585
+            }
1586
+            $userId = $user->getUID();
1587
+        }
1588
+        $root = $this->getRootFolder();
1589
+        return $root->getUserFolder($userId);
1590
+    }
1591
+
1592
+    /**
1593
+     * @return \OC\User\Manager
1594
+     * @deprecated
1595
+     */
1596
+    public function getUserManager() {
1597
+        return $this->query(IUserManager::class);
1598
+    }
1599
+
1600
+    /**
1601
+     * @return \OC\Group\Manager
1602
+     * @deprecated
1603
+     */
1604
+    public function getGroupManager() {
1605
+        return $this->query(IGroupManager::class);
1606
+    }
1607
+
1608
+    /**
1609
+     * @return \OC\User\Session
1610
+     * @deprecated
1611
+     */
1612
+    public function getUserSession() {
1613
+        return $this->query(IUserSession::class);
1614
+    }
1615
+
1616
+    /**
1617
+     * @return \OCP\ISession
1618
+     * @deprecated
1619
+     */
1620
+    public function getSession() {
1621
+        return $this->getUserSession()->getSession();
1622
+    }
1623
+
1624
+    /**
1625
+     * @param \OCP\ISession $session
1626
+     */
1627
+    public function setSession(\OCP\ISession $session) {
1628
+        $this->query(SessionStorage::class)->setSession($session);
1629
+        $this->getUserSession()->setSession($session);
1630
+        $this->query(Store::class)->setSession($session);
1631
+    }
1632
+
1633
+    /**
1634
+     * @return \OC\Authentication\TwoFactorAuth\Manager
1635
+     * @deprecated
1636
+     */
1637
+    public function getTwoFactorAuthManager() {
1638
+        return $this->query(\OC\Authentication\TwoFactorAuth\Manager::class);
1639
+    }
1640
+
1641
+    /**
1642
+     * @return \OC\NavigationManager
1643
+     * @deprecated
1644
+     */
1645
+    public function getNavigationManager() {
1646
+        return $this->query(INavigationManager::class);
1647
+    }
1648
+
1649
+    /**
1650
+     * @return \OCP\IConfig
1651
+     * @deprecated
1652
+     */
1653
+    public function getConfig() {
1654
+        return $this->query(AllConfig::class);
1655
+    }
1656
+
1657
+    /**
1658
+     * @return \OC\SystemConfig
1659
+     * @deprecated
1660
+     */
1661
+    public function getSystemConfig() {
1662
+        return $this->query(SystemConfig::class);
1663
+    }
1664
+
1665
+    /**
1666
+     * Returns the app config manager
1667
+     *
1668
+     * @return IAppConfig
1669
+     * @deprecated
1670
+     */
1671
+    public function getAppConfig() {
1672
+        return $this->query(IAppConfig::class);
1673
+    }
1674
+
1675
+    /**
1676
+     * @return IFactory
1677
+     * @deprecated
1678
+     */
1679
+    public function getL10NFactory() {
1680
+        return $this->query(IFactory::class);
1681
+    }
1682
+
1683
+    /**
1684
+     * get an L10N instance
1685
+     *
1686
+     * @param string $app appid
1687
+     * @param string $lang
1688
+     * @return IL10N
1689
+     * @deprecated
1690
+     */
1691
+    public function getL10N($app, $lang = null) {
1692
+        return $this->getL10NFactory()->get($app, $lang);
1693
+    }
1694
+
1695
+    /**
1696
+     * @return IURLGenerator
1697
+     * @deprecated
1698
+     */
1699
+    public function getURLGenerator() {
1700
+        return $this->query(IURLGenerator::class);
1701
+    }
1702
+
1703
+    /**
1704
+     * @return AppFetcher
1705
+     * @deprecated
1706
+     */
1707
+    public function getAppFetcher() {
1708
+        return $this->query(AppFetcher::class);
1709
+    }
1710
+
1711
+    /**
1712
+     * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1713
+     * getMemCacheFactory() instead.
1714
+     *
1715
+     * @return ICache
1716
+     * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1717
+     */
1718
+    public function getCache() {
1719
+        return $this->query(ICache::class);
1720
+    }
1721
+
1722
+    /**
1723
+     * Returns an \OCP\CacheFactory instance
1724
+     *
1725
+     * @return \OCP\ICacheFactory
1726
+     * @deprecated
1727
+     */
1728
+    public function getMemCacheFactory() {
1729
+        return $this->query(Factory::class);
1730
+    }
1731
+
1732
+    /**
1733
+     * Returns an \OC\RedisFactory instance
1734
+     *
1735
+     * @return \OC\RedisFactory
1736
+     * @deprecated
1737
+     */
1738
+    public function getGetRedisFactory() {
1739
+        return $this->query('RedisFactory');
1740
+    }
1741
+
1742
+
1743
+    /**
1744
+     * Returns the current session
1745
+     *
1746
+     * @return \OCP\IDBConnection
1747
+     * @deprecated
1748
+     */
1749
+    public function getDatabaseConnection() {
1750
+        return $this->query(IDBConnection::class);
1751
+    }
1752
+
1753
+    /**
1754
+     * Returns the activity manager
1755
+     *
1756
+     * @return \OCP\Activity\IManager
1757
+     * @deprecated
1758
+     */
1759
+    public function getActivityManager() {
1760
+        return $this->query(\OCP\Activity\IManager::class);
1761
+    }
1762
+
1763
+    /**
1764
+     * Returns an job list for controlling background jobs
1765
+     *
1766
+     * @return IJobList
1767
+     * @deprecated
1768
+     */
1769
+    public function getJobList() {
1770
+        return $this->query(IJobList::class);
1771
+    }
1772
+
1773
+    /**
1774
+     * Returns a logger instance
1775
+     *
1776
+     * @return ILogger
1777
+     * @deprecated
1778
+     */
1779
+    public function getLogger() {
1780
+        return $this->query(ILogger::class);
1781
+    }
1782
+
1783
+    /**
1784
+     * @return ILogFactory
1785
+     * @throws \OCP\AppFramework\QueryException
1786
+     * @deprecated
1787
+     */
1788
+    public function getLogFactory() {
1789
+        return $this->query(ILogFactory::class);
1790
+    }
1791
+
1792
+    /**
1793
+     * Returns a router for generating and matching urls
1794
+     *
1795
+     * @return IRouter
1796
+     * @deprecated
1797
+     */
1798
+    public function getRouter() {
1799
+        return $this->query(IRouter::class);
1800
+    }
1801
+
1802
+    /**
1803
+     * Returns a search instance
1804
+     *
1805
+     * @return ISearch
1806
+     * @deprecated
1807
+     */
1808
+    public function getSearch() {
1809
+        return $this->query(ISearch::class);
1810
+    }
1811
+
1812
+    /**
1813
+     * Returns a SecureRandom instance
1814
+     *
1815
+     * @return \OCP\Security\ISecureRandom
1816
+     * @deprecated
1817
+     */
1818
+    public function getSecureRandom() {
1819
+        return $this->query(ISecureRandom::class);
1820
+    }
1821
+
1822
+    /**
1823
+     * Returns a Crypto instance
1824
+     *
1825
+     * @return ICrypto
1826
+     * @deprecated
1827
+     */
1828
+    public function getCrypto() {
1829
+        return $this->query(ICrypto::class);
1830
+    }
1831
+
1832
+    /**
1833
+     * Returns a Hasher instance
1834
+     *
1835
+     * @return IHasher
1836
+     * @deprecated
1837
+     */
1838
+    public function getHasher() {
1839
+        return $this->query(IHasher::class);
1840
+    }
1841
+
1842
+    /**
1843
+     * Returns a CredentialsManager instance
1844
+     *
1845
+     * @return ICredentialsManager
1846
+     * @deprecated
1847
+     */
1848
+    public function getCredentialsManager() {
1849
+        return $this->query(ICredentialsManager::class);
1850
+    }
1851
+
1852
+    /**
1853
+     * Get the certificate manager for the user
1854
+     *
1855
+     * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
1856
+     * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in
1857
+     * @deprecated
1858
+     */
1859
+    public function getCertificateManager($userId = '') {
1860
+        if ($userId === '') {
1861
+            $userSession = $this->getUserSession();
1862
+            $user = $userSession->getUser();
1863
+            if (is_null($user)) {
1864
+                return null;
1865
+            }
1866
+            $userId = $user->getUID();
1867
+        }
1868
+        return new CertificateManager(
1869
+            $userId,
1870
+            new View(),
1871
+            $this->getConfig(),
1872
+            $this->getLogger(),
1873
+            $this->getSecureRandom()
1874
+        );
1875
+    }
1876
+
1877
+    /**
1878
+     * Returns an instance of the HTTP client service
1879
+     *
1880
+     * @return IClientService
1881
+     * @deprecated
1882
+     */
1883
+    public function getHTTPClientService() {
1884
+        return $this->query(IClientService::class);
1885
+    }
1886
+
1887
+    /**
1888
+     * Create a new event source
1889
+     *
1890
+     * @return \OCP\IEventSource
1891
+     * @deprecated
1892
+     */
1893
+    public function createEventSource() {
1894
+        return new \OC_EventSource();
1895
+    }
1896
+
1897
+    /**
1898
+     * Get the active event logger
1899
+     *
1900
+     * The returned logger only logs data when debug mode is enabled
1901
+     *
1902
+     * @return IEventLogger
1903
+     * @deprecated
1904
+     */
1905
+    public function getEventLogger() {
1906
+        return $this->query(IEventLogger::class);
1907
+    }
1908
+
1909
+    /**
1910
+     * Get the active query logger
1911
+     *
1912
+     * The returned logger only logs data when debug mode is enabled
1913
+     *
1914
+     * @return IQueryLogger
1915
+     * @deprecated
1916
+     */
1917
+    public function getQueryLogger() {
1918
+        return $this->query(IQueryLogger::class);
1919
+    }
1920
+
1921
+    /**
1922
+     * Get the manager for temporary files and folders
1923
+     *
1924
+     * @return \OCP\ITempManager
1925
+     * @deprecated
1926
+     */
1927
+    public function getTempManager() {
1928
+        return $this->query(ITempManager::class);
1929
+    }
1930
+
1931
+    /**
1932
+     * Get the app manager
1933
+     *
1934
+     * @return \OCP\App\IAppManager
1935
+     * @deprecated
1936
+     */
1937
+    public function getAppManager() {
1938
+        return $this->query(IAppManager::class);
1939
+    }
1940
+
1941
+    /**
1942
+     * Creates a new mailer
1943
+     *
1944
+     * @return IMailer
1945
+     * @deprecated
1946
+     */
1947
+    public function getMailer() {
1948
+        return $this->query(IMailer::class);
1949
+    }
1950
+
1951
+    /**
1952
+     * Get the webroot
1953
+     *
1954
+     * @return string
1955
+     * @deprecated
1956
+     */
1957
+    public function getWebRoot() {
1958
+        return $this->webRoot;
1959
+    }
1960
+
1961
+    /**
1962
+     * @return \OC\OCSClient
1963
+     * @deprecated
1964
+     */
1965
+    public function getOcsClient() {
1966
+        return $this->query('OcsClient');
1967
+    }
1968
+
1969
+    /**
1970
+     * @return IDateTimeZone
1971
+     * @deprecated
1972
+     */
1973
+    public function getDateTimeZone() {
1974
+        return $this->query(IDateTimeZone::class);
1975
+    }
1976
+
1977
+    /**
1978
+     * @return IDateTimeFormatter
1979
+     * @deprecated
1980
+     */
1981
+    public function getDateTimeFormatter() {
1982
+        return $this->query(IDateTimeFormatter::class);
1983
+    }
1984
+
1985
+    /**
1986
+     * @return IMountProviderCollection
1987
+     * @deprecated
1988
+     */
1989
+    public function getMountProviderCollection() {
1990
+        return $this->query(IMountProviderCollection::class);
1991
+    }
1992
+
1993
+    /**
1994
+     * Get the IniWrapper
1995
+     *
1996
+     * @return IniGetWrapper
1997
+     * @deprecated
1998
+     */
1999
+    public function getIniWrapper() {
2000
+        return $this->query('IniWrapper');
2001
+    }
2002
+
2003
+    /**
2004
+     * @return \OCP\Command\IBus
2005
+     * @deprecated
2006
+     */
2007
+    public function getCommandBus() {
2008
+        return $this->query('AsyncCommandBus');
2009
+    }
2010
+
2011
+    /**
2012
+     * Get the trusted domain helper
2013
+     *
2014
+     * @return TrustedDomainHelper
2015
+     * @deprecated
2016
+     */
2017
+    public function getTrustedDomainHelper() {
2018
+        return $this->query('TrustedDomainHelper');
2019
+    }
2020
+
2021
+    /**
2022
+     * Get the locking provider
2023
+     *
2024
+     * @return ILockingProvider
2025
+     * @since 8.1.0
2026
+     * @deprecated
2027
+     */
2028
+    public function getLockingProvider() {
2029
+        return $this->query(ILockingProvider::class);
2030
+    }
2031
+
2032
+    /**
2033
+     * @return IMountManager
2034
+     * @deprecated
2035
+     **/
2036
+    public function getMountManager() {
2037
+        return $this->query(IMountManager::class);
2038
+    }
2039
+
2040
+    /**
2041
+     * @return IUserMountCache
2042
+     * @deprecated
2043
+     */
2044
+    public function getUserMountCache() {
2045
+        return $this->query(IUserMountCache::class);
2046
+    }
2047
+
2048
+    /**
2049
+     * Get the MimeTypeDetector
2050
+     *
2051
+     * @return IMimeTypeDetector
2052
+     * @deprecated
2053
+     */
2054
+    public function getMimeTypeDetector() {
2055
+        return $this->query(IMimeTypeDetector::class);
2056
+    }
2057
+
2058
+    /**
2059
+     * Get the MimeTypeLoader
2060
+     *
2061
+     * @return IMimeTypeLoader
2062
+     * @deprecated
2063
+     */
2064
+    public function getMimeTypeLoader() {
2065
+        return $this->query(IMimeTypeLoader::class);
2066
+    }
2067
+
2068
+    /**
2069
+     * Get the manager of all the capabilities
2070
+     *
2071
+     * @return CapabilitiesManager
2072
+     * @deprecated
2073
+     */
2074
+    public function getCapabilitiesManager() {
2075
+        return $this->query(CapabilitiesManager::class);
2076
+    }
2077
+
2078
+    /**
2079
+     * Get the EventDispatcher
2080
+     *
2081
+     * @return EventDispatcherInterface
2082
+     * @since 8.2.0
2083
+     * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher
2084
+     */
2085
+    public function getEventDispatcher() {
2086
+        return $this->query(\OC\EventDispatcher\SymfonyAdapter::class);
2087
+    }
2088
+
2089
+    /**
2090
+     * Get the Notification Manager
2091
+     *
2092
+     * @return \OCP\Notification\IManager
2093
+     * @since 8.2.0
2094
+     * @deprecated
2095
+     */
2096
+    public function getNotificationManager() {
2097
+        return $this->query(\OCP\Notification\IManager::class);
2098
+    }
2099
+
2100
+    /**
2101
+     * @return ICommentsManager
2102
+     * @deprecated
2103
+     */
2104
+    public function getCommentsManager() {
2105
+        return $this->query(ICommentsManager::class);
2106
+    }
2107
+
2108
+    /**
2109
+     * @return \OCA\Theming\ThemingDefaults
2110
+     * @deprecated
2111
+     */
2112
+    public function getThemingDefaults() {
2113
+        return $this->query('ThemingDefaults');
2114
+    }
2115
+
2116
+    /**
2117
+     * @return \OC\IntegrityCheck\Checker
2118
+     * @deprecated
2119
+     */
2120
+    public function getIntegrityCodeChecker() {
2121
+        return $this->query('IntegrityCodeChecker');
2122
+    }
2123
+
2124
+    /**
2125
+     * @return \OC\Session\CryptoWrapper
2126
+     * @deprecated
2127
+     */
2128
+    public function getSessionCryptoWrapper() {
2129
+        return $this->query('CryptoWrapper');
2130
+    }
2131
+
2132
+    /**
2133
+     * @return CsrfTokenManager
2134
+     * @deprecated
2135
+     */
2136
+    public function getCsrfTokenManager() {
2137
+        return $this->query(CsrfTokenManager::class);
2138
+    }
2139
+
2140
+    /**
2141
+     * @return Throttler
2142
+     * @deprecated
2143
+     */
2144
+    public function getBruteForceThrottler() {
2145
+        return $this->query(Throttler::class);
2146
+    }
2147
+
2148
+    /**
2149
+     * @return IContentSecurityPolicyManager
2150
+     * @deprecated
2151
+     */
2152
+    public function getContentSecurityPolicyManager() {
2153
+        return $this->query(ContentSecurityPolicyManager::class);
2154
+    }
2155
+
2156
+    /**
2157
+     * @return ContentSecurityPolicyNonceManager
2158
+     * @deprecated
2159
+     */
2160
+    public function getContentSecurityPolicyNonceManager() {
2161
+        return $this->query('ContentSecurityPolicyNonceManager');
2162
+    }
2163
+
2164
+    /**
2165
+     * Not a public API as of 8.2, wait for 9.0
2166
+     *
2167
+     * @return \OCA\Files_External\Service\BackendService
2168
+     * @deprecated
2169
+     */
2170
+    public function getStoragesBackendService() {
2171
+        return $this->query(BackendService::class);
2172
+    }
2173
+
2174
+    /**
2175
+     * Not a public API as of 8.2, wait for 9.0
2176
+     *
2177
+     * @return \OCA\Files_External\Service\GlobalStoragesService
2178
+     * @deprecated
2179
+     */
2180
+    public function getGlobalStoragesService() {
2181
+        return $this->query(GlobalStoragesService::class);
2182
+    }
2183
+
2184
+    /**
2185
+     * Not a public API as of 8.2, wait for 9.0
2186
+     *
2187
+     * @return \OCA\Files_External\Service\UserGlobalStoragesService
2188
+     * @deprecated
2189
+     */
2190
+    public function getUserGlobalStoragesService() {
2191
+        return $this->query(UserGlobalStoragesService::class);
2192
+    }
2193
+
2194
+    /**
2195
+     * Not a public API as of 8.2, wait for 9.0
2196
+     *
2197
+     * @return \OCA\Files_External\Service\UserStoragesService
2198
+     * @deprecated
2199
+     */
2200
+    public function getUserStoragesService() {
2201
+        return $this->query(UserStoragesService::class);
2202
+    }
2203
+
2204
+    /**
2205
+     * @return \OCP\Share\IManager
2206
+     * @deprecated
2207
+     */
2208
+    public function getShareManager() {
2209
+        return $this->query(\OCP\Share\IManager::class);
2210
+    }
2211
+
2212
+    /**
2213
+     * @return \OCP\Collaboration\Collaborators\ISearch
2214
+     * @deprecated
2215
+     */
2216
+    public function getCollaboratorSearch() {
2217
+        return $this->query(\OCP\Collaboration\Collaborators\ISearch::class);
2218
+    }
2219
+
2220
+    /**
2221
+     * @return \OCP\Collaboration\AutoComplete\IManager
2222
+     * @deprecated
2223
+     */
2224
+    public function getAutoCompleteManager() {
2225
+        return $this->query(IManager::class);
2226
+    }
2227
+
2228
+    /**
2229
+     * Returns the LDAP Provider
2230
+     *
2231
+     * @return \OCP\LDAP\ILDAPProvider
2232
+     * @deprecated
2233
+     */
2234
+    public function getLDAPProvider() {
2235
+        return $this->query('LDAPProvider');
2236
+    }
2237
+
2238
+    /**
2239
+     * @return \OCP\Settings\IManager
2240
+     * @deprecated
2241
+     */
2242
+    public function getSettingsManager() {
2243
+        return $this->query('SettingsManager');
2244
+    }
2245
+
2246
+    /**
2247
+     * @return \OCP\Files\IAppData
2248
+     * @deprecated
2249
+     */
2250
+    public function getAppDataDir($app) {
2251
+        /** @var \OC\Files\AppData\Factory $factory */
2252
+        $factory = $this->query(\OC\Files\AppData\Factory::class);
2253
+        return $factory->get($app);
2254
+    }
2255
+
2256
+    /**
2257
+     * @return \OCP\Lockdown\ILockdownManager
2258
+     * @deprecated
2259
+     */
2260
+    public function getLockdownManager() {
2261
+        return $this->query('LockdownManager');
2262
+    }
2263
+
2264
+    /**
2265
+     * @return \OCP\Federation\ICloudIdManager
2266
+     * @deprecated
2267
+     */
2268
+    public function getCloudIdManager() {
2269
+        return $this->query(ICloudIdManager::class);
2270
+    }
2271
+
2272
+    /**
2273
+     * @return \OCP\GlobalScale\IConfig
2274
+     * @deprecated
2275
+     */
2276
+    public function getGlobalScaleConfig() {
2277
+        return $this->query(IConfig::class);
2278
+    }
2279
+
2280
+    /**
2281
+     * @return \OCP\Federation\ICloudFederationProviderManager
2282
+     * @deprecated
2283
+     */
2284
+    public function getCloudFederationProviderManager() {
2285
+        return $this->query(ICloudFederationProviderManager::class);
2286
+    }
2287
+
2288
+    /**
2289
+     * @return \OCP\Remote\Api\IApiFactory
2290
+     * @deprecated
2291
+     */
2292
+    public function getRemoteApiFactory() {
2293
+        return $this->query(IApiFactory::class);
2294
+    }
2295
+
2296
+    /**
2297
+     * @return \OCP\Federation\ICloudFederationFactory
2298
+     * @deprecated
2299
+     */
2300
+    public function getCloudFederationFactory() {
2301
+        return $this->query(ICloudFederationFactory::class);
2302
+    }
2303
+
2304
+    /**
2305
+     * @return \OCP\Remote\IInstanceFactory
2306
+     * @deprecated
2307
+     */
2308
+    public function getRemoteInstanceFactory() {
2309
+        return $this->query(IInstanceFactory::class);
2310
+    }
2311
+
2312
+    /**
2313
+     * @return IStorageFactory
2314
+     * @deprecated
2315
+     */
2316
+    public function getStorageFactory() {
2317
+        return $this->query(IStorageFactory::class);
2318
+    }
2319
+
2320
+    /**
2321
+     * Get the Preview GeneratorHelper
2322
+     *
2323
+     * @return GeneratorHelper
2324
+     * @since 17.0.0
2325
+     * @deprecated
2326
+     */
2327
+    public function getGeneratorHelper() {
2328
+        return $this->query(\OC\Preview\GeneratorHelper::class);
2329
+    }
2330
+
2331
+    private function registerDeprecatedAlias(string $alias, string $target) {
2332
+        $this->registerService($alias, function (ContainerInterface $container) use ($target, $alias) {
2333
+            try {
2334
+                /** @var ILogger $logger */
2335
+                $logger = $container->get(ILogger::class);
2336
+                $logger->debug('The requested alias "' . $alias . '" is depreacted. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']);
2337
+            } catch (ContainerExceptionInterface $e) {
2338
+                // Could not get logger. Continue
2339
+            }
2340
+
2341
+            return $container->get($target);
2342
+        }, false);
2343
+    }
2344 2344
 }
Please login to merge, or discard this patch.
Spacing   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -258,10 +258,10 @@  discard block
 block discarded – undo
258 258
 		// To find out if we are running from CLI or not
259 259
 		$this->registerParameter('isCLI', \OC::$CLI);
260 260
 
261
-		$this->registerService(ContainerInterface::class, function (ContainerInterface $c) {
261
+		$this->registerService(ContainerInterface::class, function(ContainerInterface $c) {
262 262
 			return $c;
263 263
 		});
264
-		$this->registerService(\OCP\IServerContainer::class, function (ContainerInterface $c) {
264
+		$this->registerService(\OCP\IServerContainer::class, function(ContainerInterface $c) {
265 265
 			return $c;
266 266
 		});
267 267
 
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 		$this->registerAlias(IActionFactory::class, ActionFactory::class);
283 283
 
284 284
 
285
-		$this->registerService(IPreview::class, function (Server $c) {
285
+		$this->registerService(IPreview::class, function(Server $c) {
286 286
 			return new PreviewManager(
287 287
 				$c->getConfig(),
288 288
 				$c->getRootFolder(),
@@ -294,13 +294,13 @@  discard block
 block discarded – undo
294 294
 		});
295 295
 		$this->registerDeprecatedAlias('PreviewManager', IPreview::class);
296 296
 
297
-		$this->registerService(\OC\Preview\Watcher::class, function (Server $c) {
297
+		$this->registerService(\OC\Preview\Watcher::class, function(Server $c) {
298 298
 			return new \OC\Preview\Watcher(
299 299
 				new \OC\Preview\Storage\Root($c->getRootFolder(), $c->getSystemConfig(), 'preview')
300 300
 			);
301 301
 		});
302 302
 
303
-		$this->registerService(\OCP\Encryption\IManager::class, function (Server $c) {
303
+		$this->registerService(\OCP\Encryption\IManager::class, function(Server $c) {
304 304
 			$view = new View();
305 305
 			$util = new Encryption\Util(
306 306
 				$view,
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 		});
320 320
 		$this->registerDeprecatedAlias('EncryptionManager', \OCP\Encryption\IManager::class);
321 321
 
322
-		$this->registerService('EncryptionFileHelper', function (Server $c) {
322
+		$this->registerService('EncryptionFileHelper', function(Server $c) {
323 323
 			$util = new Encryption\Util(
324 324
 				new View(),
325 325
 				$c->getUserManager(),
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 			);
334 334
 		});
335 335
 
336
-		$this->registerService('EncryptionKeyStorage', function (Server $c) {
336
+		$this->registerService('EncryptionKeyStorage', function(Server $c) {
337 337
 			$view = new View();
338 338
 			$util = new Encryption\Util(
339 339
 				$view,
@@ -344,30 +344,30 @@  discard block
 block discarded – undo
344 344
 
345 345
 			return new Encryption\Keys\Storage($view, $util);
346 346
 		});
347
-		$this->registerService('TagMapper', function (Server $c) {
347
+		$this->registerService('TagMapper', function(Server $c) {
348 348
 			return new TagMapper($c->getDatabaseConnection());
349 349
 		});
350 350
 
351
-		$this->registerService(\OCP\ITagManager::class, function (Server $c) {
351
+		$this->registerService(\OCP\ITagManager::class, function(Server $c) {
352 352
 			$tagMapper = $c->query('TagMapper');
353 353
 			return new TagManager($tagMapper, $c->getUserSession());
354 354
 		});
355 355
 		$this->registerDeprecatedAlias('TagManager', \OCP\ITagManager::class);
356 356
 
357
-		$this->registerService('SystemTagManagerFactory', function (Server $c) {
357
+		$this->registerService('SystemTagManagerFactory', function(Server $c) {
358 358
 			$config = $c->getConfig();
359 359
 			$factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
360 360
 			return new $factoryClass($this);
361 361
 		});
362
-		$this->registerService(ISystemTagManager::class, function (Server $c) {
362
+		$this->registerService(ISystemTagManager::class, function(Server $c) {
363 363
 			return $c->query('SystemTagManagerFactory')->getManager();
364 364
 		});
365 365
 		$this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class);
366 366
 
367
-		$this->registerService(ISystemTagObjectMapper::class, function (Server $c) {
367
+		$this->registerService(ISystemTagObjectMapper::class, function(Server $c) {
368 368
 			return $c->query('SystemTagManagerFactory')->getObjectMapper();
369 369
 		});
370
-		$this->registerService('RootFolder', function (Server $c) {
370
+		$this->registerService('RootFolder', function(Server $c) {
371 371
 			$manager = \OC\Files\Filesystem::getMountManager(null);
372 372
 			$view = new View();
373 373
 			$root = new Root(
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 
385 385
 			return $root;
386 386
 		});
387
-		$this->registerService(HookConnector::class, function (Server $c) {
387
+		$this->registerService(HookConnector::class, function(Server $c) {
388 388
 			return new HookConnector(
389 389
 				$c->query(IRootFolder::class),
390 390
 				new View(),
@@ -395,8 +395,8 @@  discard block
 block discarded – undo
395 395
 
396 396
 		$this->registerDeprecatedAlias('SystemTagObjectMapper', ISystemTagObjectMapper::class);
397 397
 
398
-		$this->registerService(IRootFolder::class, function (Server $c) {
399
-			return new LazyRoot(function () use ($c) {
398
+		$this->registerService(IRootFolder::class, function(Server $c) {
399
+			return new LazyRoot(function() use ($c) {
400 400
 				return $c->query('RootFolder');
401 401
 			});
402 402
 		});
@@ -405,44 +405,44 @@  discard block
 block discarded – undo
405 405
 		$this->registerDeprecatedAlias('UserManager', \OC\User\Manager::class);
406 406
 		$this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
407 407
 
408
-		$this->registerService(\OCP\IGroupManager::class, function (Server $c) {
408
+		$this->registerService(\OCP\IGroupManager::class, function(Server $c) {
409 409
 			$groupManager = new \OC\Group\Manager($this->getUserManager(), $c->getEventDispatcher(), $this->getLogger());
410
-			$groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
410
+			$groupManager->listen('\OC\Group', 'preCreate', function($gid) {
411 411
 				\OC_Hook::emit('OC_Group', 'pre_createGroup', ['run' => true, 'gid' => $gid]);
412 412
 
413 413
 				/** @var IEventDispatcher $dispatcher */
414 414
 				$dispatcher = $this->query(IEventDispatcher::class);
415 415
 				$dispatcher->dispatchTyped(new BeforeGroupCreatedEvent($gid));
416 416
 			});
417
-			$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $group) {
417
+			$groupManager->listen('\OC\Group', 'postCreate', function(\OC\Group\Group $group) {
418 418
 				\OC_Hook::emit('OC_User', 'post_createGroup', ['gid' => $group->getGID()]);
419 419
 
420 420
 				/** @var IEventDispatcher $dispatcher */
421 421
 				$dispatcher = $this->query(IEventDispatcher::class);
422 422
 				$dispatcher->dispatchTyped(new GroupCreatedEvent($group));
423 423
 			});
424
-			$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
424
+			$groupManager->listen('\OC\Group', 'preDelete', function(\OC\Group\Group $group) {
425 425
 				\OC_Hook::emit('OC_Group', 'pre_deleteGroup', ['run' => true, 'gid' => $group->getGID()]);
426 426
 
427 427
 				/** @var IEventDispatcher $dispatcher */
428 428
 				$dispatcher = $this->query(IEventDispatcher::class);
429 429
 				$dispatcher->dispatchTyped(new BeforeGroupDeletedEvent($group));
430 430
 			});
431
-			$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
431
+			$groupManager->listen('\OC\Group', 'postDelete', function(\OC\Group\Group $group) {
432 432
 				\OC_Hook::emit('OC_User', 'post_deleteGroup', ['gid' => $group->getGID()]);
433 433
 
434 434
 				/** @var IEventDispatcher $dispatcher */
435 435
 				$dispatcher = $this->query(IEventDispatcher::class);
436 436
 				$dispatcher->dispatchTyped(new GroupDeletedEvent($group));
437 437
 			});
438
-			$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
438
+			$groupManager->listen('\OC\Group', 'preAddUser', function(\OC\Group\Group $group, \OC\User\User $user) {
439 439
 				\OC_Hook::emit('OC_Group', 'pre_addToGroup', ['run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()]);
440 440
 
441 441
 				/** @var IEventDispatcher $dispatcher */
442 442
 				$dispatcher = $this->query(IEventDispatcher::class);
443 443
 				$dispatcher->dispatchTyped(new BeforeUserAddedEvent($group, $user));
444 444
 			});
445
-			$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
445
+			$groupManager->listen('\OC\Group', 'postAddUser', function(\OC\Group\Group $group, \OC\User\User $user) {
446 446
 				\OC_Hook::emit('OC_Group', 'post_addToGroup', ['uid' => $user->getUID(), 'gid' => $group->getGID()]);
447 447
 				//Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
448 448
 				\OC_Hook::emit('OC_User', 'post_addToGroup', ['uid' => $user->getUID(), 'gid' => $group->getGID()]);
@@ -451,12 +451,12 @@  discard block
 block discarded – undo
451 451
 				$dispatcher = $this->query(IEventDispatcher::class);
452 452
 				$dispatcher->dispatchTyped(new UserAddedEvent($group, $user));
453 453
 			});
454
-			$groupManager->listen('\OC\Group', 'preRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
454
+			$groupManager->listen('\OC\Group', 'preRemoveUser', function(\OC\Group\Group $group, \OC\User\User $user) {
455 455
 				/** @var IEventDispatcher $dispatcher */
456 456
 				$dispatcher = $this->query(IEventDispatcher::class);
457 457
 				$dispatcher->dispatchTyped(new BeforeUserRemovedEvent($group, $user));
458 458
 			});
459
-			$groupManager->listen('\OC\Group', 'postRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
459
+			$groupManager->listen('\OC\Group', 'postRemoveUser', function(\OC\Group\Group $group, \OC\User\User $user) {
460 460
 				/** @var IEventDispatcher $dispatcher */
461 461
 				$dispatcher = $this->query(IEventDispatcher::class);
462 462
 				$dispatcher->dispatchTyped(new UserRemovedEvent($group, $user));
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
 		});
466 466
 		$this->registerDeprecatedAlias('GroupManager', \OCP\IGroupManager::class);
467 467
 
468
-		$this->registerService(Store::class, function (Server $c) {
468
+		$this->registerService(Store::class, function(Server $c) {
469 469
 			$session = $c->getSession();
470 470
 			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
471 471
 				$tokenProvider = $c->query(IProvider::class);
@@ -476,13 +476,13 @@  discard block
 block discarded – undo
476 476
 			return new Store($session, $logger, $tokenProvider);
477 477
 		});
478 478
 		$this->registerAlias(IStore::class, Store::class);
479
-		$this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) {
479
+		$this->registerService(Authentication\Token\DefaultTokenMapper::class, function(Server $c) {
480 480
 			$dbConnection = $c->getDatabaseConnection();
481 481
 			return new Authentication\Token\DefaultTokenMapper($dbConnection);
482 482
 		});
483 483
 		$this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
484 484
 
485
-		$this->registerService(\OC\User\Session::class, function (Server $c) {
485
+		$this->registerService(\OC\User\Session::class, function(Server $c) {
486 486
 			$manager = $c->getUserManager();
487 487
 			$session = new \OC\Session\Memory('');
488 488
 			$timeFactory = new TimeFactory();
@@ -507,14 +507,14 @@  discard block
 block discarded – undo
507 507
 				$c->getLogger(),
508 508
 				$c->query(IEventDispatcher::class)
509 509
 			);
510
-			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
510
+			$userSession->listen('\OC\User', 'preCreateUser', function($uid, $password) {
511 511
 				\OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]);
512 512
 
513 513
 				/** @var IEventDispatcher $dispatcher */
514 514
 				$dispatcher = $this->query(IEventDispatcher::class);
515 515
 				$dispatcher->dispatchTyped(new BeforeUserCreatedEvent($uid, $password));
516 516
 			});
517
-			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
517
+			$userSession->listen('\OC\User', 'postCreateUser', function($user, $password) {
518 518
 				/** @var $user \OC\User\User */
519 519
 				\OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]);
520 520
 
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 				$dispatcher = $this->query(IEventDispatcher::class);
523 523
 				$dispatcher->dispatchTyped(new UserCreatedEvent($user, $password));
524 524
 			});
525
-			$userSession->listen('\OC\User', 'preDelete', function ($user) use ($legacyDispatcher) {
525
+			$userSession->listen('\OC\User', 'preDelete', function($user) use ($legacyDispatcher) {
526 526
 				/** @var $user \OC\User\User */
527 527
 				\OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]);
528 528
 				$legacyDispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user));
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
 				$dispatcher = $this->query(IEventDispatcher::class);
532 532
 				$dispatcher->dispatchTyped(new BeforeUserDeletedEvent($user));
533 533
 			});
534
-			$userSession->listen('\OC\User', 'postDelete', function ($user) {
534
+			$userSession->listen('\OC\User', 'postDelete', function($user) {
535 535
 				/** @var $user \OC\User\User */
536 536
 				\OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]);
537 537
 
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
 				$dispatcher = $this->query(IEventDispatcher::class);
540 540
 				$dispatcher->dispatchTyped(new UserDeletedEvent($user));
541 541
 			});
542
-			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
542
+			$userSession->listen('\OC\User', 'preSetPassword', function($user, $password, $recoveryPassword) {
543 543
 				/** @var $user \OC\User\User */
544 544
 				\OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
545 545
 
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 				$dispatcher = $this->query(IEventDispatcher::class);
548 548
 				$dispatcher->dispatchTyped(new BeforePasswordUpdatedEvent($user, $password, $recoveryPassword));
549 549
 			});
550
-			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
550
+			$userSession->listen('\OC\User', 'postSetPassword', function($user, $password, $recoveryPassword) {
551 551
 				/** @var $user \OC\User\User */
552 552
 				\OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
553 553
 
@@ -555,14 +555,14 @@  discard block
 block discarded – undo
555 555
 				$dispatcher = $this->query(IEventDispatcher::class);
556 556
 				$dispatcher->dispatchTyped(new PasswordUpdatedEvent($user, $password, $recoveryPassword));
557 557
 			});
558
-			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
558
+			$userSession->listen('\OC\User', 'preLogin', function($uid, $password) {
559 559
 				\OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]);
560 560
 
561 561
 				/** @var IEventDispatcher $dispatcher */
562 562
 				$dispatcher = $this->query(IEventDispatcher::class);
563 563
 				$dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password));
564 564
 			});
565
-			$userSession->listen('\OC\User', 'postLogin', function ($user, $password, $isTokenLogin) {
565
+			$userSession->listen('\OC\User', 'postLogin', function($user, $password, $isTokenLogin) {
566 566
 				/** @var $user \OC\User\User */
567 567
 				\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'isTokenLogin' => $isTokenLogin]);
568 568
 
@@ -570,12 +570,12 @@  discard block
 block discarded – undo
570 570
 				$dispatcher = $this->query(IEventDispatcher::class);
571 571
 				$dispatcher->dispatchTyped(new UserLoggedInEvent($user, $password, $isTokenLogin));
572 572
 			});
573
-			$userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) {
573
+			$userSession->listen('\OC\User', 'preRememberedLogin', function($uid) {
574 574
 				/** @var IEventDispatcher $dispatcher */
575 575
 				$dispatcher = $this->query(IEventDispatcher::class);
576 576
 				$dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid));
577 577
 			});
578
-			$userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
578
+			$userSession->listen('\OC\User', 'postRememberedLogin', function($user, $password) {
579 579
 				/** @var $user \OC\User\User */
580 580
 				\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]);
581 581
 
@@ -583,19 +583,19 @@  discard block
 block discarded – undo
583 583
 				$dispatcher = $this->query(IEventDispatcher::class);
584 584
 				$dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password));
585 585
 			});
586
-			$userSession->listen('\OC\User', 'logout', function ($user) {
586
+			$userSession->listen('\OC\User', 'logout', function($user) {
587 587
 				\OC_Hook::emit('OC_User', 'logout', []);
588 588
 
589 589
 				/** @var IEventDispatcher $dispatcher */
590 590
 				$dispatcher = $this->query(IEventDispatcher::class);
591 591
 				$dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user));
592 592
 			});
593
-			$userSession->listen('\OC\User', 'postLogout', function ($user) {
593
+			$userSession->listen('\OC\User', 'postLogout', function($user) {
594 594
 				/** @var IEventDispatcher $dispatcher */
595 595
 				$dispatcher = $this->query(IEventDispatcher::class);
596 596
 				$dispatcher->dispatchTyped(new UserLoggedOutEvent($user));
597 597
 			});
598
-			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
598
+			$userSession->listen('\OC\User', 'changeUser', function($user, $feature, $value, $oldValue) {
599 599
 				/** @var $user \OC\User\User */
600 600
 				\OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]);
601 601
 
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
 		$this->registerAlias(INavigationManager::class, \OC\NavigationManager::class);
614 614
 		$this->registerDeprecatedAlias('NavigationManager', INavigationManager::class);
615 615
 
616
-		$this->registerService(\OC\AllConfig::class, function (Server $c) {
616
+		$this->registerService(\OC\AllConfig::class, function(Server $c) {
617 617
 			return new \OC\AllConfig(
618 618
 				$c->getSystemConfig()
619 619
 			);
@@ -621,18 +621,18 @@  discard block
 block discarded – undo
621 621
 		$this->registerDeprecatedAlias('AllConfig', \OC\AllConfig::class);
622 622
 		$this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
623 623
 
624
-		$this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
624
+		$this->registerService(\OC\SystemConfig::class, function($c) use ($config) {
625 625
 			return new \OC\SystemConfig($config);
626 626
 		});
627 627
 		$this->registerDeprecatedAlias('SystemConfig', \OC\SystemConfig::class);
628 628
 
629
-		$this->registerService(\OC\AppConfig::class, function (Server $c) {
629
+		$this->registerService(\OC\AppConfig::class, function(Server $c) {
630 630
 			return new \OC\AppConfig($c->getDatabaseConnection());
631 631
 		});
632 632
 		$this->registerDeprecatedAlias('AppConfig', \OC\AppConfig::class);
633 633
 		$this->registerAlias(IAppConfig::class, \OC\AppConfig::class);
634 634
 
635
-		$this->registerService(IFactory::class, function (Server $c) {
635
+		$this->registerService(IFactory::class, function(Server $c) {
636 636
 			return new \OC\L10N\Factory(
637 637
 				$c->getConfig(),
638 638
 				$c->getRequest(),
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
 		});
643 643
 		$this->registerDeprecatedAlias('L10NFactory', IFactory::class);
644 644
 
645
-		$this->registerService(IURLGenerator::class, function (Server $c) {
645
+		$this->registerService(IURLGenerator::class, function(Server $c) {
646 646
 			$config = $c->getConfig();
647 647
 			$cacheFactory = $c->getMemCacheFactory();
648 648
 			$request = $c->getRequest();
@@ -657,12 +657,12 @@  discard block
 block discarded – undo
657 657
 		$this->registerDeprecatedAlias('AppFetcher', AppFetcher::class);
658 658
 		$this->registerDeprecatedAlias('CategoryFetcher', CategoryFetcher::class);
659 659
 
660
-		$this->registerService(ICache::class, function ($c) {
660
+		$this->registerService(ICache::class, function($c) {
661 661
 			return new Cache\File();
662 662
 		});
663 663
 		$this->registerDeprecatedAlias('UserCache', ICache::class);
664 664
 
665
-		$this->registerService(Factory::class, function (Server $c) {
665
+		$this->registerService(Factory::class, function(Server $c) {
666 666
 			$arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(),
667 667
 				ArrayCache::class,
668 668
 				ArrayCache::class,
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 				$version = implode(',', $v);
677 677
 				$instanceId = \OC_Util::getInstanceId();
678 678
 				$path = \OC::$SERVERROOT;
679
-				$prefix = md5($instanceId . '-' . $version . '-' . $path);
679
+				$prefix = md5($instanceId.'-'.$version.'-'.$path);
680 680
 				return new \OC\Memcache\Factory($prefix, $c->getLogger(),
681 681
 					$config->getSystemValue('memcache.local', null),
682 682
 					$config->getSystemValue('memcache.distributed', null),
@@ -688,12 +688,12 @@  discard block
 block discarded – undo
688 688
 		$this->registerDeprecatedAlias('MemCacheFactory', Factory::class);
689 689
 		$this->registerAlias(ICacheFactory::class, Factory::class);
690 690
 
691
-		$this->registerService('RedisFactory', function (Server $c) {
691
+		$this->registerService('RedisFactory', function(Server $c) {
692 692
 			$systemConfig = $c->getSystemConfig();
693 693
 			return new RedisFactory($systemConfig);
694 694
 		});
695 695
 
696
-		$this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
696
+		$this->registerService(\OCP\Activity\IManager::class, function(Server $c) {
697 697
 			return new \OC\Activity\Manager(
698 698
 				$c->getRequest(),
699 699
 				$c->getUserSession(),
@@ -703,14 +703,14 @@  discard block
 block discarded – undo
703 703
 		});
704 704
 		$this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class);
705 705
 
706
-		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
706
+		$this->registerService(\OCP\Activity\IEventMerger::class, function(Server $c) {
707 707
 			return new \OC\Activity\EventMerger(
708 708
 				$c->getL10N('lib')
709 709
 			);
710 710
 		});
711 711
 		$this->registerAlias(IValidator::class, Validator::class);
712 712
 
713
-		$this->registerService(AvatarManager::class, function (Server $c) {
713
+		$this->registerService(AvatarManager::class, function(Server $c) {
714 714
 			return new AvatarManager(
715 715
 				$c->query(\OC\User\Manager::class),
716 716
 				$c->getAppDataDir('avatar'),
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
 		$this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
726 726
 		$this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
727 727
 
728
-		$this->registerService(\OC\Log::class, function (Server $c) {
728
+		$this->registerService(\OC\Log::class, function(Server $c) {
729 729
 			$logType = $c->query(AllConfig::class)->getSystemValue('log_type', 'file');
730 730
 			$factory = new LogFactory($c, $this->getSystemConfig());
731 731
 			$logger = $factory->get($logType);
@@ -738,11 +738,11 @@  discard block
 block discarded – undo
738 738
 		// PSR-3 logger
739 739
 		$this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class);
740 740
 
741
-		$this->registerService(ILogFactory::class, function (Server $c) {
741
+		$this->registerService(ILogFactory::class, function(Server $c) {
742 742
 			return new LogFactory($c, $this->getSystemConfig());
743 743
 		});
744 744
 
745
-		$this->registerService(IJobList::class, function (Server $c) {
745
+		$this->registerService(IJobList::class, function(Server $c) {
746 746
 			$config = $c->getConfig();
747 747
 			return new \OC\BackgroundJob\JobList(
748 748
 				$c->getDatabaseConnection(),
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
 		});
753 753
 		$this->registerDeprecatedAlias('JobList', IJobList::class);
754 754
 
755
-		$this->registerService(IRouter::class, function (Server $c) {
755
+		$this->registerService(IRouter::class, function(Server $c) {
756 756
 			$cacheFactory = $c->getMemCacheFactory();
757 757
 			$logger = $c->getLogger();
758 758
 			if ($cacheFactory->isLocalCacheAvailable()) {
@@ -764,39 +764,39 @@  discard block
 block discarded – undo
764 764
 		});
765 765
 		$this->registerDeprecatedAlias('Router', IRouter::class);
766 766
 
767
-		$this->registerService(ISearch::class, function ($c) {
767
+		$this->registerService(ISearch::class, function($c) {
768 768
 			return new Search();
769 769
 		});
770 770
 		$this->registerDeprecatedAlias('Search', ISearch::class);
771 771
 
772
-		$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
772
+		$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function($c) {
773 773
 			return new \OC\Security\RateLimiting\Backend\MemoryCache(
774 774
 				$this->getMemCacheFactory(),
775 775
 				new \OC\AppFramework\Utility\TimeFactory()
776 776
 			);
777 777
 		});
778 778
 
779
-		$this->registerService(\OCP\Security\ISecureRandom::class, function ($c) {
779
+		$this->registerService(\OCP\Security\ISecureRandom::class, function($c) {
780 780
 			return new SecureRandom();
781 781
 		});
782 782
 		$this->registerDeprecatedAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
783 783
 
784
-		$this->registerService(ICrypto::class, function (Server $c) {
784
+		$this->registerService(ICrypto::class, function(Server $c) {
785 785
 			return new Crypto($c->getConfig(), $c->getSecureRandom());
786 786
 		});
787 787
 		$this->registerDeprecatedAlias('Crypto', ICrypto::class);
788 788
 
789
-		$this->registerService(IHasher::class, function (Server $c) {
789
+		$this->registerService(IHasher::class, function(Server $c) {
790 790
 			return new Hasher($c->getConfig());
791 791
 		});
792 792
 		$this->registerDeprecatedAlias('Hasher', IHasher::class);
793 793
 
794
-		$this->registerService(ICredentialsManager::class, function (Server $c) {
794
+		$this->registerService(ICredentialsManager::class, function(Server $c) {
795 795
 			return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
796 796
 		});
797 797
 		$this->registerDeprecatedAlias('CredentialsManager', ICredentialsManager::class);
798 798
 
799
-		$this->registerService(IDBConnection::class, function (Server $c) {
799
+		$this->registerService(IDBConnection::class, function(Server $c) {
800 800
 			$systemConfig = $c->getSystemConfig();
801 801
 			$factory = new \OC\DB\ConnectionFactory($systemConfig);
802 802
 			$type = $systemConfig->getValue('dbtype', 'sqlite');
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
 		$this->registerDeprecatedAlias('DatabaseConnection', IDBConnection::class);
812 812
 
813 813
 
814
-		$this->registerService(IClientService::class, function (Server $c) {
814
+		$this->registerService(IClientService::class, function(Server $c) {
815 815
 			$user = \OC_User::getUser();
816 816
 			$uid = $user ? $user : null;
817 817
 			return new ClientService(
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
 			);
828 828
 		});
829 829
 		$this->registerDeprecatedAlias('HttpClientService', IClientService::class);
830
-		$this->registerService(IEventLogger::class, function (Server $c) {
830
+		$this->registerService(IEventLogger::class, function(Server $c) {
831 831
 			$eventLogger = new EventLogger();
832 832
 			if ($c->getSystemConfig()->getValue('debug', false)) {
833 833
 				// In debug mode, module is being activated by default
@@ -837,7 +837,7 @@  discard block
 block discarded – undo
837 837
 		});
838 838
 		$this->registerDeprecatedAlias('EventLogger', IEventLogger::class);
839 839
 
840
-		$this->registerService(IQueryLogger::class, function (Server $c) {
840
+		$this->registerService(IQueryLogger::class, function(Server $c) {
841 841
 			$queryLogger = new QueryLogger();
842 842
 			if ($c->getSystemConfig()->getValue('debug', false)) {
843 843
 				// In debug mode, module is being activated by default
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
 		});
848 848
 		$this->registerDeprecatedAlias('QueryLogger', IQueryLogger::class);
849 849
 
850
-		$this->registerService(TempManager::class, function (Server $c) {
850
+		$this->registerService(TempManager::class, function(Server $c) {
851 851
 			return new TempManager(
852 852
 				$c->getLogger(),
853 853
 				$c->getConfig()
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
 		$this->registerDeprecatedAlias('TempManager', TempManager::class);
857 857
 		$this->registerAlias(ITempManager::class, TempManager::class);
858 858
 
859
-		$this->registerService(AppManager::class, function (Server $c) {
859
+		$this->registerService(AppManager::class, function(Server $c) {
860 860
 			return new \OC\App\AppManager(
861 861
 				$c->getUserSession(),
862 862
 				$c->getConfig(),
@@ -870,7 +870,7 @@  discard block
 block discarded – undo
870 870
 		$this->registerDeprecatedAlias('AppManager', AppManager::class);
871 871
 		$this->registerAlias(IAppManager::class, AppManager::class);
872 872
 
873
-		$this->registerService(IDateTimeZone::class, function (Server $c) {
873
+		$this->registerService(IDateTimeZone::class, function(Server $c) {
874 874
 			return new DateTimeZone(
875 875
 				$c->getConfig(),
876 876
 				$c->getSession()
@@ -878,7 +878,7 @@  discard block
 block discarded – undo
878 878
 		});
879 879
 		$this->registerDeprecatedAlias('DateTimeZone', IDateTimeZone::class);
880 880
 
881
-		$this->registerService(IDateTimeFormatter::class, function (Server $c) {
881
+		$this->registerService(IDateTimeFormatter::class, function(Server $c) {
882 882
 			$language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
883 883
 
884 884
 			return new DateTimeFormatter(
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
 		});
889 889
 		$this->registerDeprecatedAlias('DateTimeFormatter', IDateTimeFormatter::class);
890 890
 
891
-		$this->registerService(IUserMountCache::class, function (Server $c) {
891
+		$this->registerService(IUserMountCache::class, function(Server $c) {
892 892
 			$mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
893 893
 			$listener = new UserMountCacheListener($mountCache);
894 894
 			$listener->listen($c->getUserManager());
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
 		});
897 897
 		$this->registerDeprecatedAlias('UserMountCache', IUserMountCache::class);
898 898
 
899
-		$this->registerService(IMountProviderCollection::class, function (Server $c) {
899
+		$this->registerService(IMountProviderCollection::class, function(Server $c) {
900 900
 			$loader = \OC\Files\Filesystem::getLoader();
901 901
 			$mountCache = $c->query(IUserMountCache::class);
902 902
 			$manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
@@ -912,10 +912,10 @@  discard block
 block discarded – undo
912 912
 		});
913 913
 		$this->registerDeprecatedAlias('MountConfigManager', IMountProviderCollection::class);
914 914
 
915
-		$this->registerService('IniWrapper', function ($c) {
915
+		$this->registerService('IniWrapper', function($c) {
916 916
 			return new IniGetWrapper();
917 917
 		});
918
-		$this->registerService('AsyncCommandBus', function (Server $c) {
918
+		$this->registerService('AsyncCommandBus', function(Server $c) {
919 919
 			$busClass = $c->getConfig()->getSystemValue('commandbus');
920 920
 			if ($busClass) {
921 921
 				[$app, $class] = explode('::', $busClass, 2);
@@ -931,10 +931,10 @@  discard block
 block discarded – undo
931 931
 			}
932 932
 		});
933 933
 		$this->registerAlias(IBus::class, 'AsyncCommandBus');
934
-		$this->registerService('TrustedDomainHelper', function ($c) {
934
+		$this->registerService('TrustedDomainHelper', function($c) {
935 935
 			return new TrustedDomainHelper($this->getConfig());
936 936
 		});
937
-		$this->registerService(Throttler::class, function (Server $c) {
937
+		$this->registerService(Throttler::class, function(Server $c) {
938 938
 			return new Throttler(
939 939
 				$c->getDatabaseConnection(),
940 940
 				new TimeFactory(),
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
 			);
944 944
 		});
945 945
 		$this->registerDeprecatedAlias('Throttler', Throttler::class);
946
-		$this->registerService('IntegrityCodeChecker', function (Server $c) {
946
+		$this->registerService('IntegrityCodeChecker', function(Server $c) {
947 947
 			// IConfig and IAppManager requires a working database. This code
948 948
 			// might however be called when ownCloud is not yet setup.
949 949
 			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
@@ -965,7 +965,7 @@  discard block
 block discarded – undo
965 965
 				$c->getMimeTypeDetector()
966 966
 			);
967 967
 		});
968
-		$this->registerService(\OCP\IRequest::class, function ($c) {
968
+		$this->registerService(\OCP\IRequest::class, function($c) {
969 969
 			if (isset($this['urlParams'])) {
970 970
 				$urlParams = $this['urlParams'];
971 971
 			} else {
@@ -1001,7 +1001,7 @@  discard block
 block discarded – undo
1001 1001
 		});
1002 1002
 		$this->registerDeprecatedAlias('Request', \OCP\IRequest::class);
1003 1003
 
1004
-		$this->registerService(IMailer::class, function (Server $c) {
1004
+		$this->registerService(IMailer::class, function(Server $c) {
1005 1005
 			return new Mailer(
1006 1006
 				$c->getConfig(),
1007 1007
 				$c->getLogger(),
@@ -1014,7 +1014,7 @@  discard block
 block discarded – undo
1014 1014
 		});
1015 1015
 		$this->registerDeprecatedAlias('Mailer', IMailer::class);
1016 1016
 
1017
-		$this->registerService('LDAPProvider', function (Server $c) {
1017
+		$this->registerService('LDAPProvider', function(Server $c) {
1018 1018
 			$config = $c->getConfig();
1019 1019
 			$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
1020 1020
 			if (is_null($factoryClass)) {
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
 			$factory = new $factoryClass($this);
1025 1025
 			return $factory->getLDAPProvider();
1026 1026
 		});
1027
-		$this->registerService(ILockingProvider::class, function (Server $c) {
1027
+		$this->registerService(ILockingProvider::class, function(Server $c) {
1028 1028
 			$ini = $c->getIniWrapper();
1029 1029
 			$config = $c->getConfig();
1030 1030
 			$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
@@ -1047,31 +1047,31 @@  discard block
 block discarded – undo
1047 1047
 		});
1048 1048
 		$this->registerDeprecatedAlias('LockingProvider', ILockingProvider::class);
1049 1049
 
1050
-		$this->registerService(IMountManager::class, function () {
1050
+		$this->registerService(IMountManager::class, function() {
1051 1051
 			return new \OC\Files\Mount\Manager();
1052 1052
 		});
1053 1053
 		$this->registerDeprecatedAlias('MountManager', IMountManager::class);
1054 1054
 
1055
-		$this->registerService(IMimeTypeDetector::class, function (Server $c) {
1055
+		$this->registerService(IMimeTypeDetector::class, function(Server $c) {
1056 1056
 			return new \OC\Files\Type\Detection(
1057 1057
 				$c->getURLGenerator(),
1058 1058
 				$c->getLogger(),
1059 1059
 				\OC::$configDir,
1060
-				\OC::$SERVERROOT . '/resources/config/'
1060
+				\OC::$SERVERROOT.'/resources/config/'
1061 1061
 			);
1062 1062
 		});
1063 1063
 		$this->registerDeprecatedAlias('MimeTypeDetector', IMimeTypeDetector::class);
1064 1064
 
1065
-		$this->registerService(IMimeTypeLoader::class, function (Server $c) {
1065
+		$this->registerService(IMimeTypeLoader::class, function(Server $c) {
1066 1066
 			return new \OC\Files\Type\Loader(
1067 1067
 				$c->getDatabaseConnection()
1068 1068
 			);
1069 1069
 		});
1070 1070
 		$this->registerDeprecatedAlias('MimeTypeLoader', IMimeTypeLoader::class);
1071
-		$this->registerService(BundleFetcher::class, function () {
1071
+		$this->registerService(BundleFetcher::class, function() {
1072 1072
 			return new BundleFetcher($this->getL10N('lib'));
1073 1073
 		});
1074
-		$this->registerService(\OCP\Notification\IManager::class, function (Server $c) {
1074
+		$this->registerService(\OCP\Notification\IManager::class, function(Server $c) {
1075 1075
 			return new Manager(
1076 1076
 				$c->query(IValidator::class),
1077 1077
 				$c->getLogger()
@@ -1079,26 +1079,26 @@  discard block
 block discarded – undo
1079 1079
 		});
1080 1080
 		$this->registerDeprecatedAlias('NotificationManager', \OCP\Notification\IManager::class);
1081 1081
 
1082
-		$this->registerService(CapabilitiesManager::class, function (Server $c) {
1082
+		$this->registerService(CapabilitiesManager::class, function(Server $c) {
1083 1083
 			$manager = new CapabilitiesManager($c->getLogger());
1084
-			$manager->registerCapability(function () use ($c) {
1084
+			$manager->registerCapability(function() use ($c) {
1085 1085
 				return new \OC\OCS\CoreCapabilities($c->getConfig());
1086 1086
 			});
1087
-			$manager->registerCapability(function () use ($c) {
1087
+			$manager->registerCapability(function() use ($c) {
1088 1088
 				return $c->query(\OC\Security\Bruteforce\Capabilities::class);
1089 1089
 			});
1090 1090
 			return $manager;
1091 1091
 		});
1092 1092
 		$this->registerDeprecatedAlias('CapabilitiesManager', CapabilitiesManager::class);
1093 1093
 
1094
-		$this->registerService(ICommentsManager::class, function (Server $c) {
1094
+		$this->registerService(ICommentsManager::class, function(Server $c) {
1095 1095
 			$config = $c->getConfig();
1096 1096
 			$factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
1097 1097
 			/** @var \OCP\Comments\ICommentsManagerFactory $factory */
1098 1098
 			$factory = new $factoryClass($this);
1099 1099
 			$manager = $factory->getManager();
1100 1100
 
1101
-			$manager->registerDisplayNameResolver('user', function ($id) use ($c) {
1101
+			$manager->registerDisplayNameResolver('user', function($id) use ($c) {
1102 1102
 				$manager = $c->getUserManager();
1103 1103
 				$user = $manager->get($id);
1104 1104
 				if (is_null($user)) {
@@ -1114,7 +1114,7 @@  discard block
 block discarded – undo
1114 1114
 		});
1115 1115
 		$this->registerDeprecatedAlias('CommentsManager', ICommentsManager::class);
1116 1116
 
1117
-		$this->registerService('ThemingDefaults', function (Server $c) {
1117
+		$this->registerService('ThemingDefaults', function(Server $c) {
1118 1118
 			/*
1119 1119
 			 * Dark magic for autoloader.
1120 1120
 			 * If we do a class_exists it will try to load the class which will
@@ -1142,7 +1142,7 @@  discard block
 block discarded – undo
1142 1142
 			}
1143 1143
 			return new \OC_Defaults();
1144 1144
 		});
1145
-		$this->registerService(SCSSCacher::class, function (Server $c) {
1145
+		$this->registerService(SCSSCacher::class, function(Server $c) {
1146 1146
 			return new SCSSCacher(
1147 1147
 				$c->getLogger(),
1148 1148
 				$c->query(\OC\Files\AppData\Factory::class),
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
 				new TimeFactory()
1156 1156
 			);
1157 1157
 		});
1158
-		$this->registerService(JSCombiner::class, function (Server $c) {
1158
+		$this->registerService(JSCombiner::class, function(Server $c) {
1159 1159
 			return new JSCombiner(
1160 1160
 				$c->getAppDataDir('js'),
1161 1161
 				$c->getURLGenerator(),
@@ -1168,7 +1168,7 @@  discard block
 block discarded – undo
1168 1168
 		$this->registerDeprecatedAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class);
1169 1169
 		$this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class);
1170 1170
 
1171
-		$this->registerService('CryptoWrapper', function (Server $c) {
1171
+		$this->registerService('CryptoWrapper', function(Server $c) {
1172 1172
 			// FIXME: Instantiiated here due to cyclic dependency
1173 1173
 			$request = new Request(
1174 1174
 				[
@@ -1193,7 +1193,7 @@  discard block
 block discarded – undo
1193 1193
 				$request
1194 1194
 			);
1195 1195
 		});
1196
-		$this->registerService(CsrfTokenManager::class, function (Server $c) {
1196
+		$this->registerService(CsrfTokenManager::class, function(Server $c) {
1197 1197
 			$tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
1198 1198
 
1199 1199
 			return new CsrfTokenManager(
@@ -1202,20 +1202,20 @@  discard block
 block discarded – undo
1202 1202
 			);
1203 1203
 		});
1204 1204
 		$this->registerDeprecatedAlias('CsrfTokenManager', CsrfTokenManager::class);
1205
-		$this->registerService(SessionStorage::class, function (Server $c) {
1205
+		$this->registerService(SessionStorage::class, function(Server $c) {
1206 1206
 			return new SessionStorage($c->getSession());
1207 1207
 		});
1208 1208
 		$this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class);
1209 1209
 		$this->registerDeprecatedAlias('ContentSecurityPolicyManager', ContentSecurityPolicyManager::class);
1210 1210
 
1211
-		$this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) {
1211
+		$this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) {
1212 1212
 			return new ContentSecurityPolicyNonceManager(
1213 1213
 				$c->getCsrfTokenManager(),
1214 1214
 				$c->getRequest()
1215 1215
 			);
1216 1216
 		});
1217 1217
 
1218
-		$this->registerService(\OCP\Share\IManager::class, function (Server $c) {
1218
+		$this->registerService(\OCP\Share\IManager::class, function(Server $c) {
1219 1219
 			$config = $c->getConfig();
1220 1220
 			$factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
1221 1221
 			/** @var \OCP\Share\IProviderFactory $factory */
@@ -1244,7 +1244,7 @@  discard block
 block discarded – undo
1244 1244
 		});
1245 1245
 		$this->registerDeprecatedAlias('ShareManager', \OCP\Share\IManager::class);
1246 1246
 
1247
-		$this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) {
1247
+		$this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) {
1248 1248
 			$instance = new Collaboration\Collaborators\Search($c);
1249 1249
 
1250 1250
 			// register default plugins
@@ -1264,7 +1264,7 @@  discard block
 block discarded – undo
1264 1264
 		$this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class);
1265 1265
 		$this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class);
1266 1266
 
1267
-		$this->registerService('SettingsManager', function (Server $c) {
1267
+		$this->registerService('SettingsManager', function(Server $c) {
1268 1268
 			$manager = new \OC\Settings\Manager(
1269 1269
 				$c->getLogger(),
1270 1270
 				$c->getL10NFactory(),
@@ -1273,34 +1273,34 @@  discard block
 block discarded – undo
1273 1273
 			);
1274 1274
 			return $manager;
1275 1275
 		});
1276
-		$this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) {
1276
+		$this->registerService(\OC\Files\AppData\Factory::class, function(Server $c) {
1277 1277
 			return new \OC\Files\AppData\Factory(
1278 1278
 				$c->getRootFolder(),
1279 1279
 				$c->getSystemConfig()
1280 1280
 			);
1281 1281
 		});
1282 1282
 
1283
-		$this->registerService('LockdownManager', function (Server $c) {
1284
-			return new LockdownManager(function () use ($c) {
1283
+		$this->registerService('LockdownManager', function(Server $c) {
1284
+			return new LockdownManager(function() use ($c) {
1285 1285
 				return $c->getSession();
1286 1286
 			});
1287 1287
 		});
1288 1288
 
1289
-		$this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) {
1289
+		$this->registerService(\OCP\OCS\IDiscoveryService::class, function(Server $c) {
1290 1290
 			return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService());
1291 1291
 		});
1292 1292
 
1293
-		$this->registerService(ICloudIdManager::class, function (Server $c) {
1293
+		$this->registerService(ICloudIdManager::class, function(Server $c) {
1294 1294
 			return new CloudIdManager();
1295 1295
 		});
1296 1296
 
1297 1297
 		$this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class);
1298 1298
 
1299
-		$this->registerService(ICloudFederationProviderManager::class, function (Server $c) {
1299
+		$this->registerService(ICloudFederationProviderManager::class, function(Server $c) {
1300 1300
 			return new CloudFederationProviderManager($c->getAppManager(), $c->getHTTPClientService(), $c->getCloudIdManager(), $c->getLogger());
1301 1301
 		});
1302 1302
 
1303
-		$this->registerService(ICloudFederationFactory::class, function (Server $c) {
1303
+		$this->registerService(ICloudFederationFactory::class, function(Server $c) {
1304 1304
 			return new CloudFederationFactory();
1305 1305
 		});
1306 1306
 
@@ -1310,24 +1310,24 @@  discard block
 block discarded – undo
1310 1310
 		$this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1311 1311
 		$this->registerDeprecatedAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1312 1312
 
1313
-		$this->registerService(Defaults::class, function (Server $c) {
1313
+		$this->registerService(Defaults::class, function(Server $c) {
1314 1314
 			return new Defaults(
1315 1315
 				$c->getThemingDefaults()
1316 1316
 			);
1317 1317
 		});
1318 1318
 		$this->registerDeprecatedAlias('Defaults', \OCP\Defaults::class);
1319 1319
 
1320
-		$this->registerService(\OCP\ISession::class, function (SimpleContainer $c) {
1320
+		$this->registerService(\OCP\ISession::class, function(SimpleContainer $c) {
1321 1321
 			return $c->query(\OCP\IUserSession::class)->getSession();
1322 1322
 		});
1323 1323
 
1324
-		$this->registerService(IShareHelper::class, function (Server $c) {
1324
+		$this->registerService(IShareHelper::class, function(Server $c) {
1325 1325
 			return new ShareHelper(
1326 1326
 				$c->query(\OCP\Share\IManager::class)
1327 1327
 			);
1328 1328
 		});
1329 1329
 
1330
-		$this->registerService(Installer::class, function (Server $c) {
1330
+		$this->registerService(Installer::class, function(Server $c) {
1331 1331
 			return new Installer(
1332 1332
 				$c->getAppFetcher(),
1333 1333
 				$c->getHTTPClientService(),
@@ -1338,16 +1338,16 @@  discard block
 block discarded – undo
1338 1338
 			);
1339 1339
 		});
1340 1340
 
1341
-		$this->registerService(IApiFactory::class, function (Server $c) {
1341
+		$this->registerService(IApiFactory::class, function(Server $c) {
1342 1342
 			return new ApiFactory($c->getHTTPClientService());
1343 1343
 		});
1344 1344
 
1345
-		$this->registerService(IInstanceFactory::class, function (Server $c) {
1345
+		$this->registerService(IInstanceFactory::class, function(Server $c) {
1346 1346
 			$memcacheFactory = $c->getMemCacheFactory();
1347 1347
 			return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService());
1348 1348
 		});
1349 1349
 
1350
-		$this->registerService(IContactsStore::class, function (Server $c) {
1350
+		$this->registerService(IContactsStore::class, function(Server $c) {
1351 1351
 			return new ContactsStore(
1352 1352
 				$c->getContactsManager(),
1353 1353
 				$c->getConfig(),
@@ -1358,7 +1358,7 @@  discard block
 block discarded – undo
1358 1358
 		$this->registerAlias(IContactsStore::class, ContactsStore::class);
1359 1359
 		$this->registerAlias(IAccountManager::class, AccountManager::class);
1360 1360
 
1361
-		$this->registerService(IStorageFactory::class, function () {
1361
+		$this->registerService(IStorageFactory::class, function() {
1362 1362
 			return new StorageFactory();
1363 1363
 		});
1364 1364
 
@@ -1407,7 +1407,7 @@  discard block
 block discarded – undo
1407 1407
 		$dispatcher = $this->getEventDispatcher();
1408 1408
 
1409 1409
 		// Delete avatar on user deletion
1410
-		$dispatcher->addListener('OCP\IUser::preDelete', function (GenericEvent $e) {
1410
+		$dispatcher->addListener('OCP\IUser::preDelete', function(GenericEvent $e) {
1411 1411
 			$logger = $this->getLogger();
1412 1412
 			$manager = $this->getAvatarManager();
1413 1413
 			/** @var IUser $user */
@@ -1420,11 +1420,11 @@  discard block
 block discarded – undo
1420 1420
 				// no avatar to remove
1421 1421
 			} catch (\Exception $e) {
1422 1422
 				// Ignore exceptions
1423
-				$logger->info('Could not cleanup avatar of ' . $user->getUID());
1423
+				$logger->info('Could not cleanup avatar of '.$user->getUID());
1424 1424
 			}
1425 1425
 		});
1426 1426
 
1427
-		$dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) {
1427
+		$dispatcher->addListener('OCP\IUser::changeUser', function(GenericEvent $e) {
1428 1428
 			$manager = $this->getAvatarManager();
1429 1429
 			/** @var IUser $user */
1430 1430
 			$user = $e->getSubject();
@@ -2329,11 +2329,11 @@  discard block
 block discarded – undo
2329 2329
 	}
2330 2330
 
2331 2331
 	private function registerDeprecatedAlias(string $alias, string $target) {
2332
-		$this->registerService($alias, function (ContainerInterface $container) use ($target, $alias) {
2332
+		$this->registerService($alias, function(ContainerInterface $container) use ($target, $alias) {
2333 2333
 			try {
2334 2334
 				/** @var ILogger $logger */
2335 2335
 				$logger = $container->get(ILogger::class);
2336
-				$logger->debug('The requested alias "' . $alias . '" is depreacted. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']);
2336
+				$logger->debug('The requested alias "'.$alias.'" is depreacted. Please request "'.$target.'" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']);
2337 2337
 			} catch (ContainerExceptionInterface $e) {
2338 2338
 				// Could not get logger. Continue
2339 2339
 			}
Please login to merge, or discard this patch.
apps/files_trashbin/lib/Trashbin.php 2 patches
Indentation   +989 added lines, -989 removed lines patch added patch discarded remove patch
@@ -58,993 +58,993 @@
 block discarded – undo
58 58
 
59 59
 class Trashbin {
60 60
 
61
-	// unit: percentage; 50% of available disk space/quota
62
-	public const DEFAULTMAXSIZE = 50;
63
-
64
-	/**
65
-	 * Whether versions have already be rescanned during this PHP request
66
-	 *
67
-	 * @var bool
68
-	 */
69
-	private static $scannedVersions = false;
70
-
71
-	/**
72
-	 * Ensure we don't need to scan the file during the move to trash
73
-	 * by triggering the scan in the pre-hook
74
-	 *
75
-	 * @param array $params
76
-	 */
77
-	public static function ensureFileScannedHook($params) {
78
-		try {
79
-			self::getUidAndFilename($params['path']);
80
-		} catch (NotFoundException $e) {
81
-			// nothing to scan for non existing files
82
-		}
83
-	}
84
-
85
-	/**
86
-	 * get the UID of the owner of the file and the path to the file relative to
87
-	 * owners files folder
88
-	 *
89
-	 * @param string $filename
90
-	 * @return array
91
-	 * @throws \OC\User\NoUserException
92
-	 */
93
-	public static function getUidAndFilename($filename) {
94
-		$uid = Filesystem::getOwner($filename);
95
-		$userManager = \OC::$server->getUserManager();
96
-		// if the user with the UID doesn't exists, e.g. because the UID points
97
-		// to a remote user with a federated cloud ID we use the current logged-in
98
-		// user. We need a valid local user to move the file to the right trash bin
99
-		if (!$userManager->userExists($uid)) {
100
-			$uid = User::getUser();
101
-		}
102
-		if (!$uid) {
103
-			// no owner, usually because of share link from ext storage
104
-			return [null, null];
105
-		}
106
-		Filesystem::initMountPoints($uid);
107
-		if ($uid !== User::getUser()) {
108
-			$info = Filesystem::getFileInfo($filename);
109
-			$ownerView = new View('/' . $uid . '/files');
110
-			try {
111
-				$filename = $ownerView->getPath($info['fileid']);
112
-			} catch (NotFoundException $e) {
113
-				$filename = null;
114
-			}
115
-		}
116
-		return [$uid, $filename];
117
-	}
118
-
119
-	/**
120
-	 * get original location of files for user
121
-	 *
122
-	 * @param string $user
123
-	 * @return array (filename => array (timestamp => original location))
124
-	 */
125
-	public static function getLocations($user) {
126
-		$query = \OC_DB::prepare('SELECT `id`, `timestamp`, `location`'
127
-			. ' FROM `*PREFIX*files_trash` WHERE `user`=?');
128
-		$result = $query->execute([$user]);
129
-		$array = [];
130
-		while ($row = $result->fetchRow()) {
131
-			if (isset($array[$row['id']])) {
132
-				$array[$row['id']][$row['timestamp']] = $row['location'];
133
-			} else {
134
-				$array[$row['id']] = [$row['timestamp'] => $row['location']];
135
-			}
136
-		}
137
-		return $array;
138
-	}
139
-
140
-	/**
141
-	 * get original location of file
142
-	 *
143
-	 * @param string $user
144
-	 * @param string $filename
145
-	 * @param string $timestamp
146
-	 * @return string original location
147
-	 */
148
-	public static function getLocation($user, $filename, $timestamp) {
149
-		$query = \OC_DB::prepare('SELECT `location` FROM `*PREFIX*files_trash`'
150
-			. ' WHERE `user`=? AND `id`=? AND `timestamp`=?');
151
-		$result = $query->execute([$user, $filename, $timestamp])->fetchAll();
152
-		if (isset($result[0]['location'])) {
153
-			return $result[0]['location'];
154
-		} else {
155
-			return false;
156
-		}
157
-	}
158
-
159
-	private static function setUpTrash($user) {
160
-		$view = new View('/' . $user);
161
-		if (!$view->is_dir('files_trashbin')) {
162
-			$view->mkdir('files_trashbin');
163
-		}
164
-		if (!$view->is_dir('files_trashbin/files')) {
165
-			$view->mkdir('files_trashbin/files');
166
-		}
167
-		if (!$view->is_dir('files_trashbin/versions')) {
168
-			$view->mkdir('files_trashbin/versions');
169
-		}
170
-		if (!$view->is_dir('files_trashbin/keys')) {
171
-			$view->mkdir('files_trashbin/keys');
172
-		}
173
-	}
174
-
175
-
176
-	/**
177
-	 * copy file to owners trash
178
-	 *
179
-	 * @param string $sourcePath
180
-	 * @param string $owner
181
-	 * @param string $targetPath
182
-	 * @param $user
183
-	 * @param integer $timestamp
184
-	 */
185
-	private static function copyFilesToUser($sourcePath, $owner, $targetPath, $user, $timestamp) {
186
-		self::setUpTrash($owner);
187
-
188
-		$targetFilename = basename($targetPath);
189
-		$targetLocation = dirname($targetPath);
190
-
191
-		$sourceFilename = basename($sourcePath);
192
-
193
-		$view = new View('/');
194
-
195
-		$target = $user . '/files_trashbin/files/' . $targetFilename . '.d' . $timestamp;
196
-		$source = $owner . '/files_trashbin/files/' . $sourceFilename . '.d' . $timestamp;
197
-		$free = $view->free_space($target);
198
-		$isUnknownOrUnlimitedFreeSpace = $free < 0;
199
-		$isEnoughFreeSpaceLeft = $view->filesize($source) < $free;
200
-		if ($isUnknownOrUnlimitedFreeSpace || $isEnoughFreeSpaceLeft) {
201
-			self::copy_recursive($source, $target, $view);
202
-		}
203
-
204
-
205
-		if ($view->file_exists($target)) {
206
-			$query = \OC_DB::prepare("INSERT INTO `*PREFIX*files_trash` (`id`,`timestamp`,`location`,`user`) VALUES (?,?,?,?)");
207
-			$result = $query->execute([$targetFilename, $timestamp, $targetLocation, $user]);
208
-			if (!$result) {
209
-				\OC::$server->getLogger()->error('trash bin database couldn\'t be updated for the files owner', ['app' => 'files_trashbin']);
210
-			}
211
-		}
212
-	}
213
-
214
-
215
-	/**
216
-	 * move file to the trash bin
217
-	 *
218
-	 * @param string $file_path path to the deleted file/directory relative to the files root directory
219
-	 * @param bool $ownerOnly delete for owner only (if file gets moved out of a shared folder)
220
-	 *
221
-	 * @return bool
222
-	 */
223
-	public static function move2trash($file_path, $ownerOnly = false) {
224
-		// get the user for which the filesystem is setup
225
-		$root = Filesystem::getRoot();
226
-		[, $user] = explode('/', $root);
227
-		[$owner, $ownerPath] = self::getUidAndFilename($file_path);
228
-
229
-		// if no owner found (ex: ext storage + share link), will use the current user's trashbin then
230
-		if (is_null($owner)) {
231
-			$owner = $user;
232
-			$ownerPath = $file_path;
233
-		}
234
-
235
-		$ownerView = new View('/' . $owner);
236
-		// file has been deleted in between
237
-		if (is_null($ownerPath) || $ownerPath === '' || !$ownerView->file_exists('/files/' . $ownerPath)) {
238
-			return true;
239
-		}
240
-
241
-		self::setUpTrash($user);
242
-		if ($owner !== $user) {
243
-			// also setup for owner
244
-			self::setUpTrash($owner);
245
-		}
246
-
247
-		$path_parts = pathinfo($ownerPath);
248
-
249
-		$filename = $path_parts['basename'];
250
-		$location = $path_parts['dirname'];
251
-		/** @var ITimeFactory $timeFactory */
252
-		$timeFactory = \OC::$server->query(ITimeFactory::class);
253
-		$timestamp = $timeFactory->getTime();
254
-
255
-		$lockingProvider = \OC::$server->getLockingProvider();
256
-
257
-		// disable proxy to prevent recursive calls
258
-		$trashPath = '/files_trashbin/files/' . $filename . '.d' . $timestamp;
259
-		$gotLock = false;
260
-
261
-		while (!$gotLock) {
262
-			try {
263
-				/** @var \OC\Files\Storage\Storage $trashStorage */
264
-				[$trashStorage, $trashInternalPath] = $ownerView->resolvePath($trashPath);
265
-
266
-				$trashStorage->acquireLock($trashInternalPath, ILockingProvider::LOCK_EXCLUSIVE, $lockingProvider);
267
-				$gotLock = true;
268
-			} catch (LockedException $e) {
269
-				// a file with the same name is being deleted concurrently
270
-				// nudge the timestamp a bit to resolve the conflict
271
-
272
-				$timestamp = $timestamp + 1;
273
-
274
-				$trashPath = '/files_trashbin/files/' . $filename . '.d' . $timestamp;
275
-			}
276
-		}
277
-
278
-		/** @var \OC\Files\Storage\Storage $sourceStorage */
279
-		[$sourceStorage, $sourceInternalPath] = $ownerView->resolvePath('/files/' . $ownerPath);
280
-
281
-		try {
282
-			$moveSuccessful = true;
283
-			if ($trashStorage->file_exists($trashInternalPath)) {
284
-				$trashStorage->unlink($trashInternalPath);
285
-			}
286
-			$trashStorage->moveFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
287
-		} catch (\OCA\Files_Trashbin\Exceptions\CopyRecursiveException $e) {
288
-			$moveSuccessful = false;
289
-			if ($trashStorage->file_exists($trashInternalPath)) {
290
-				$trashStorage->unlink($trashInternalPath);
291
-			}
292
-			\OC::$server->getLogger()->error('Couldn\'t move ' . $file_path . ' to the trash bin', ['app' => 'files_trashbin']);
293
-		}
294
-
295
-		if ($sourceStorage->file_exists($sourceInternalPath)) { // failed to delete the original file, abort
296
-			if ($sourceStorage->is_dir($sourceInternalPath)) {
297
-				$sourceStorage->rmdir($sourceInternalPath);
298
-			} else {
299
-				$sourceStorage->unlink($sourceInternalPath);
300
-			}
301
-			return false;
302
-		}
303
-
304
-		$trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
305
-
306
-		if ($moveSuccessful) {
307
-			$query = \OC_DB::prepare("INSERT INTO `*PREFIX*files_trash` (`id`,`timestamp`,`location`,`user`) VALUES (?,?,?,?)");
308
-			$result = $query->execute([$filename, $timestamp, $location, $owner]);
309
-			if (!$result) {
310
-				\OC::$server->getLogger()->error('trash bin database couldn\'t be updated', ['app' => 'files_trashbin']);
311
-			}
312
-			\OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_moveToTrash', ['filePath' => Filesystem::normalizePath($file_path),
313
-				'trashPath' => Filesystem::normalizePath($filename . '.d' . $timestamp)]);
314
-
315
-			self::retainVersions($filename, $owner, $ownerPath, $timestamp);
316
-
317
-			// if owner !== user we need to also add a copy to the users trash
318
-			if ($user !== $owner && $ownerOnly === false) {
319
-				self::copyFilesToUser($ownerPath, $owner, $file_path, $user, $timestamp);
320
-			}
321
-		}
322
-
323
-		$trashStorage->releaseLock($trashInternalPath, ILockingProvider::LOCK_EXCLUSIVE, $lockingProvider);
324
-
325
-		self::scheduleExpire($user);
326
-
327
-		// if owner !== user we also need to update the owners trash size
328
-		if ($owner !== $user) {
329
-			self::scheduleExpire($owner);
330
-		}
331
-
332
-		return $moveSuccessful;
333
-	}
334
-
335
-	/**
336
-	 * Move file versions to trash so that they can be restored later
337
-	 *
338
-	 * @param string $filename of deleted file
339
-	 * @param string $owner owner user id
340
-	 * @param string $ownerPath path relative to the owner's home storage
341
-	 * @param integer $timestamp when the file was deleted
342
-	 */
343
-	private static function retainVersions($filename, $owner, $ownerPath, $timestamp) {
344
-		if (\OCP\App::isEnabled('files_versions') && !empty($ownerPath)) {
345
-			$user = User::getUser();
346
-			$rootView = new View('/');
347
-
348
-			if ($rootView->is_dir($owner . '/files_versions/' . $ownerPath)) {
349
-				if ($owner !== $user) {
350
-					self::copy_recursive($owner . '/files_versions/' . $ownerPath, $owner . '/files_trashbin/versions/' . basename($ownerPath) . '.d' . $timestamp, $rootView);
351
-				}
352
-				self::move($rootView, $owner . '/files_versions/' . $ownerPath, $user . '/files_trashbin/versions/' . $filename . '.d' . $timestamp);
353
-			} elseif ($versions = \OCA\Files_Versions\Storage::getVersions($owner, $ownerPath)) {
354
-				foreach ($versions as $v) {
355
-					if ($owner !== $user) {
356
-						self::copy($rootView, $owner . '/files_versions' . $v['path'] . '.v' . $v['version'], $owner . '/files_trashbin/versions/' . $v['name'] . '.v' . $v['version'] . '.d' . $timestamp);
357
-					}
358
-					self::move($rootView, $owner . '/files_versions' . $v['path'] . '.v' . $v['version'], $user . '/files_trashbin/versions/' . $filename . '.v' . $v['version'] . '.d' . $timestamp);
359
-				}
360
-			}
361
-		}
362
-	}
363
-
364
-	/**
365
-	 * Move a file or folder on storage level
366
-	 *
367
-	 * @param View $view
368
-	 * @param string $source
369
-	 * @param string $target
370
-	 * @return bool
371
-	 */
372
-	private static function move(View $view, $source, $target) {
373
-		/** @var \OC\Files\Storage\Storage $sourceStorage */
374
-		[$sourceStorage, $sourceInternalPath] = $view->resolvePath($source);
375
-		/** @var \OC\Files\Storage\Storage $targetStorage */
376
-		[$targetStorage, $targetInternalPath] = $view->resolvePath($target);
377
-		/** @var \OC\Files\Storage\Storage $ownerTrashStorage */
378
-
379
-		$result = $targetStorage->moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
380
-		if ($result) {
381
-			$targetStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
382
-		}
383
-		return $result;
384
-	}
385
-
386
-	/**
387
-	 * Copy a file or folder on storage level
388
-	 *
389
-	 * @param View $view
390
-	 * @param string $source
391
-	 * @param string $target
392
-	 * @return bool
393
-	 */
394
-	private static function copy(View $view, $source, $target) {
395
-		/** @var \OC\Files\Storage\Storage $sourceStorage */
396
-		[$sourceStorage, $sourceInternalPath] = $view->resolvePath($source);
397
-		/** @var \OC\Files\Storage\Storage $targetStorage */
398
-		[$targetStorage, $targetInternalPath] = $view->resolvePath($target);
399
-		/** @var \OC\Files\Storage\Storage $ownerTrashStorage */
400
-
401
-		$result = $targetStorage->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
402
-		if ($result) {
403
-			$targetStorage->getUpdater()->update($targetInternalPath);
404
-		}
405
-		return $result;
406
-	}
407
-
408
-	/**
409
-	 * Restore a file or folder from trash bin
410
-	 *
411
-	 * @param string $file path to the deleted file/folder relative to "files_trashbin/files/",
412
-	 * including the timestamp suffix ".d12345678"
413
-	 * @param string $filename name of the file/folder
414
-	 * @param int $timestamp time when the file/folder was deleted
415
-	 *
416
-	 * @return bool true on success, false otherwise
417
-	 */
418
-	public static function restore($file, $filename, $timestamp) {
419
-		$user = User::getUser();
420
-		$view = new View('/' . $user);
421
-
422
-		$location = '';
423
-		if ($timestamp) {
424
-			$location = self::getLocation($user, $filename, $timestamp);
425
-			if ($location === false) {
426
-				\OC::$server->getLogger()->error('trash bin database inconsistent! ($user: ' . $user . ' $filename: ' . $filename . ', $timestamp: ' . $timestamp . ')', ['app' => 'files_trashbin']);
427
-			} else {
428
-				// if location no longer exists, restore file in the root directory
429
-				if ($location !== '/' &&
430
-					(!$view->is_dir('files/' . $location) ||
431
-						!$view->isCreatable('files/' . $location))
432
-				) {
433
-					$location = '';
434
-				}
435
-			}
436
-		}
437
-
438
-		// we need a  extension in case a file/dir with the same name already exists
439
-		$uniqueFilename = self::getUniqueFilename($location, $filename, $view);
440
-
441
-		$source = Filesystem::normalizePath('files_trashbin/files/' . $file);
442
-		$target = Filesystem::normalizePath('files/' . $location . '/' . $uniqueFilename);
443
-		if (!$view->file_exists($source)) {
444
-			return false;
445
-		}
446
-		$mtime = $view->filemtime($source);
447
-
448
-		// restore file
449
-		if (!$view->isCreatable(dirname($target))) {
450
-			throw new NotPermittedException("Can't restore trash item because the target folder is not writable");
451
-		}
452
-		$restoreResult = $view->rename($source, $target);
453
-
454
-		// handle the restore result
455
-		if ($restoreResult) {
456
-			$fakeRoot = $view->getRoot();
457
-			$view->chroot('/' . $user . '/files');
458
-			$view->touch('/' . $location . '/' . $uniqueFilename, $mtime);
459
-			$view->chroot($fakeRoot);
460
-			\OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', ['filePath' => Filesystem::normalizePath('/' . $location . '/' . $uniqueFilename),
461
-				'trashPath' => Filesystem::normalizePath($file)]);
462
-
463
-			self::restoreVersions($view, $file, $filename, $uniqueFilename, $location, $timestamp);
464
-
465
-			if ($timestamp) {
466
-				$query = \OC_DB::prepare('DELETE FROM `*PREFIX*files_trash` WHERE `user`=? AND `id`=? AND `timestamp`=?');
467
-				$query->execute([$user, $filename, $timestamp]);
468
-			}
469
-
470
-			return true;
471
-		}
472
-
473
-		return false;
474
-	}
475
-
476
-	/**
477
-	 * restore versions from trash bin
478
-	 *
479
-	 * @param View $view file view
480
-	 * @param string $file complete path to file
481
-	 * @param string $filename name of file once it was deleted
482
-	 * @param string $uniqueFilename new file name to restore the file without overwriting existing files
483
-	 * @param string $location location if file
484
-	 * @param int $timestamp deletion time
485
-	 * @return false|null
486
-	 */
487
-	private static function restoreVersions(View $view, $file, $filename, $uniqueFilename, $location, $timestamp) {
488
-		if (\OCP\App::isEnabled('files_versions')) {
489
-			$user = User::getUser();
490
-			$rootView = new View('/');
491
-
492
-			$target = Filesystem::normalizePath('/' . $location . '/' . $uniqueFilename);
493
-
494
-			[$owner, $ownerPath] = self::getUidAndFilename($target);
495
-
496
-			// file has been deleted in between
497
-			if (empty($ownerPath)) {
498
-				return false;
499
-			}
500
-
501
-			if ($timestamp) {
502
-				$versionedFile = $filename;
503
-			} else {
504
-				$versionedFile = $file;
505
-			}
506
-
507
-			if ($view->is_dir('/files_trashbin/versions/' . $file)) {
508
-				$rootView->rename(Filesystem::normalizePath($user . '/files_trashbin/versions/' . $file), Filesystem::normalizePath($owner . '/files_versions/' . $ownerPath));
509
-			} elseif ($versions = self::getVersionsFromTrash($versionedFile, $timestamp, $user)) {
510
-				foreach ($versions as $v) {
511
-					if ($timestamp) {
512
-						$rootView->rename($user . '/files_trashbin/versions/' . $versionedFile . '.v' . $v . '.d' . $timestamp, $owner . '/files_versions/' . $ownerPath . '.v' . $v);
513
-					} else {
514
-						$rootView->rename($user . '/files_trashbin/versions/' . $versionedFile . '.v' . $v, $owner . '/files_versions/' . $ownerPath . '.v' . $v);
515
-					}
516
-				}
517
-			}
518
-		}
519
-	}
520
-
521
-	/**
522
-	 * delete all files from the trash
523
-	 */
524
-	public static function deleteAll() {
525
-		$user = User::getUser();
526
-		$userRoot = \OC::$server->getUserFolder($user)->getParent();
527
-		$view = new View('/' . $user);
528
-		$fileInfos = $view->getDirectoryContent('files_trashbin/files');
529
-
530
-		try {
531
-			$trash = $userRoot->get('files_trashbin');
532
-		} catch (NotFoundException $e) {
533
-			return false;
534
-		}
535
-
536
-		// Array to store the relative path in (after the file is deleted, the view won't be able to relativise the path anymore)
537
-		$filePaths = [];
538
-		foreach ($fileInfos as $fileInfo) {
539
-			$filePaths[] = $view->getRelativePath($fileInfo->getPath());
540
-		}
541
-		unset($fileInfos); // save memory
542
-
543
-		// Bulk PreDelete-Hook
544
-		\OC_Hook::emit('\OCP\Trashbin', 'preDeleteAll', ['paths' => $filePaths]);
545
-
546
-		// Single-File Hooks
547
-		foreach ($filePaths as $path) {
548
-			self::emitTrashbinPreDelete($path);
549
-		}
550
-
551
-		// actual file deletion
552
-		$trash->delete();
553
-		$query = \OC_DB::prepare('DELETE FROM `*PREFIX*files_trash` WHERE `user`=?');
554
-		$query->execute([$user]);
555
-
556
-		// Bulk PostDelete-Hook
557
-		\OC_Hook::emit('\OCP\Trashbin', 'deleteAll', ['paths' => $filePaths]);
558
-
559
-		// Single-File Hooks
560
-		foreach ($filePaths as $path) {
561
-			self::emitTrashbinPostDelete($path);
562
-		}
563
-
564
-		$trash = $userRoot->newFolder('files_trashbin');
565
-		$trash->newFolder('files');
566
-
567
-		return true;
568
-	}
569
-
570
-	/**
571
-	 * wrapper function to emit the 'preDelete' hook of \OCP\Trashbin before a file is deleted
572
-	 *
573
-	 * @param string $path
574
-	 */
575
-	protected static function emitTrashbinPreDelete($path) {
576
-		\OC_Hook::emit('\OCP\Trashbin', 'preDelete', ['path' => $path]);
577
-	}
578
-
579
-	/**
580
-	 * wrapper function to emit the 'delete' hook of \OCP\Trashbin after a file has been deleted
581
-	 *
582
-	 * @param string $path
583
-	 */
584
-	protected static function emitTrashbinPostDelete($path) {
585
-		\OC_Hook::emit('\OCP\Trashbin', 'delete', ['path' => $path]);
586
-	}
587
-
588
-	/**
589
-	 * delete file from trash bin permanently
590
-	 *
591
-	 * @param string $filename path to the file
592
-	 * @param string $user
593
-	 * @param int $timestamp of deletion time
594
-	 *
595
-	 * @return int size of deleted files
596
-	 */
597
-	public static function delete($filename, $user, $timestamp = null) {
598
-		$userRoot = \OC::$server->getUserFolder($user)->getParent();
599
-		$view = new View('/' . $user);
600
-		$size = 0;
601
-
602
-		if ($timestamp) {
603
-			$query = \OC_DB::prepare('DELETE FROM `*PREFIX*files_trash` WHERE `user`=? AND `id`=? AND `timestamp`=?');
604
-			$query->execute([$user, $filename, $timestamp]);
605
-			$file = $filename . '.d' . $timestamp;
606
-		} else {
607
-			$file = $filename;
608
-		}
609
-
610
-		$size += self::deleteVersions($view, $file, $filename, $timestamp, $user);
611
-
612
-		try {
613
-			$node = $userRoot->get('/files_trashbin/files/' . $file);
614
-		} catch (NotFoundException $e) {
615
-			return $size;
616
-		}
617
-
618
-		if ($node instanceof Folder) {
619
-			$size += self::calculateSize(new View('/' . $user . '/files_trashbin/files/' . $file));
620
-		} elseif ($node instanceof File) {
621
-			$size += $view->filesize('/files_trashbin/files/' . $file);
622
-		}
623
-
624
-		self::emitTrashbinPreDelete('/files_trashbin/files/' . $file);
625
-		$node->delete();
626
-		self::emitTrashbinPostDelete('/files_trashbin/files/' . $file);
627
-
628
-		return $size;
629
-	}
630
-
631
-	/**
632
-	 * @param View $view
633
-	 * @param string $file
634
-	 * @param string $filename
635
-	 * @param integer|null $timestamp
636
-	 * @param string $user
637
-	 * @return int
638
-	 */
639
-	private static function deleteVersions(View $view, $file, $filename, $timestamp, $user) {
640
-		$size = 0;
641
-		if (\OCP\App::isEnabled('files_versions')) {
642
-			if ($view->is_dir('files_trashbin/versions/' . $file)) {
643
-				$size += self::calculateSize(new View('/' . $user . '/files_trashbin/versions/' . $file));
644
-				$view->unlink('files_trashbin/versions/' . $file);
645
-			} elseif ($versions = self::getVersionsFromTrash($filename, $timestamp, $user)) {
646
-				foreach ($versions as $v) {
647
-					if ($timestamp) {
648
-						$size += $view->filesize('/files_trashbin/versions/' . $filename . '.v' . $v . '.d' . $timestamp);
649
-						$view->unlink('/files_trashbin/versions/' . $filename . '.v' . $v . '.d' . $timestamp);
650
-					} else {
651
-						$size += $view->filesize('/files_trashbin/versions/' . $filename . '.v' . $v);
652
-						$view->unlink('/files_trashbin/versions/' . $filename . '.v' . $v);
653
-					}
654
-				}
655
-			}
656
-		}
657
-		return $size;
658
-	}
659
-
660
-	/**
661
-	 * check to see whether a file exists in trashbin
662
-	 *
663
-	 * @param string $filename path to the file
664
-	 * @param int $timestamp of deletion time
665
-	 * @return bool true if file exists, otherwise false
666
-	 */
667
-	public static function file_exists($filename, $timestamp = null) {
668
-		$user = User::getUser();
669
-		$view = new View('/' . $user);
670
-
671
-		if ($timestamp) {
672
-			$filename = $filename . '.d' . $timestamp;
673
-		}
674
-
675
-		$target = Filesystem::normalizePath('files_trashbin/files/' . $filename);
676
-		return $view->file_exists($target);
677
-	}
678
-
679
-	/**
680
-	 * deletes used space for trash bin in db if user was deleted
681
-	 *
682
-	 * @param string $uid id of deleted user
683
-	 * @return bool result of db delete operation
684
-	 */
685
-	public static function deleteUser($uid) {
686
-		$query = \OC_DB::prepare('DELETE FROM `*PREFIX*files_trash` WHERE `user`=?');
687
-		return $query->execute([$uid]);
688
-	}
689
-
690
-	/**
691
-	 * calculate remaining free space for trash bin
692
-	 *
693
-	 * @param integer $trashbinSize current size of the trash bin
694
-	 * @param string $user
695
-	 * @return int available free space for trash bin
696
-	 */
697
-	private static function calculateFreeSpace($trashbinSize, $user) {
698
-		$config = \OC::$server->getConfig();
699
-		$systemTrashbinSize = (int)$config->getAppValue('files_trashbin', 'trashbin_size', '-1');
700
-		$userTrashbinSize = (int)$config->getUserValue($user, 'files_trashbin', 'trashbin_size', '-1');
701
-		$configuredTrashbinSize = ($userTrashbinSize < 0) ? $systemTrashbinSize : $userTrashbinSize;
702
-		if ($configuredTrashbinSize) {
703
-			return $configuredTrashbinSize - $trashbinSize;
704
-		}
705
-
706
-		$softQuota = true;
707
-		$userObject = \OC::$server->getUserManager()->get($user);
708
-		if (is_null($userObject)) {
709
-			return 0;
710
-		}
711
-		$quota = $userObject->getQuota();
712
-		if ($quota === null || $quota === 'none') {
713
-			$quota = Filesystem::free_space('/');
714
-			$softQuota = false;
715
-			// inf or unknown free space
716
-			if ($quota < 0) {
717
-				$quota = PHP_INT_MAX;
718
-			}
719
-		} else {
720
-			$quota = \OCP\Util::computerFileSize($quota);
721
-		}
722
-
723
-		// calculate available space for trash bin
724
-		// subtract size of files and current trash bin size from quota
725
-		if ($softQuota) {
726
-			$userFolder = \OC::$server->getUserFolder($user);
727
-			if (is_null($userFolder)) {
728
-				return 0;
729
-			}
730
-			$free = $quota - $userFolder->getSize(false); // remaining free space for user
731
-			if ($free > 0) {
732
-				$availableSpace = ($free * self::DEFAULTMAXSIZE / 100) - $trashbinSize; // how much space can be used for versions
733
-			} else {
734
-				$availableSpace = $free - $trashbinSize;
735
-			}
736
-		} else {
737
-			$availableSpace = $quota;
738
-		}
739
-
740
-		return $availableSpace;
741
-	}
742
-
743
-	/**
744
-	 * resize trash bin if necessary after a new file was added to Nextcloud
745
-	 *
746
-	 * @param string $user user id
747
-	 */
748
-	public static function resizeTrash($user) {
749
-		$size = self::getTrashbinSize($user);
750
-
751
-		$freeSpace = self::calculateFreeSpace($size, $user);
752
-
753
-		if ($freeSpace < 0) {
754
-			self::scheduleExpire($user);
755
-		}
756
-	}
757
-
758
-	/**
759
-	 * clean up the trash bin
760
-	 *
761
-	 * @param string $user
762
-	 */
763
-	public static function expire($user) {
764
-		$trashBinSize = self::getTrashbinSize($user);
765
-		$availableSpace = self::calculateFreeSpace($trashBinSize, $user);
766
-
767
-		$dirContent = Helper::getTrashFiles('/', $user, 'mtime');
768
-
769
-		// delete all files older then $retention_obligation
770
-		[$delSize, $count] = self::deleteExpiredFiles($dirContent, $user);
771
-
772
-		$availableSpace += $delSize;
773
-
774
-		// delete files from trash until we meet the trash bin size limit again
775
-		self::deleteFiles(array_slice($dirContent, $count), $user, $availableSpace);
776
-	}
777
-
778
-	/**
779
-	 * @param string $user
780
-	 */
781
-	private static function scheduleExpire($user) {
782
-		// let the admin disable auto expire
783
-		/** @var Application $application */
784
-		$application = \OC::$server->query(Application::class);
785
-		$expiration = $application->getContainer()->query('Expiration');
786
-		if ($expiration->isEnabled()) {
787
-			\OC::$server->getCommandBus()->push(new Expire($user));
788
-		}
789
-	}
790
-
791
-	/**
792
-	 * if the size limit for the trash bin is reached, we delete the oldest
793
-	 * files in the trash bin until we meet the limit again
794
-	 *
795
-	 * @param array $files
796
-	 * @param string $user
797
-	 * @param int $availableSpace available disc space
798
-	 * @return int size of deleted files
799
-	 */
800
-	protected static function deleteFiles($files, $user, $availableSpace) {
801
-		/** @var Application $application */
802
-		$application = \OC::$server->query(Application::class);
803
-		$expiration = $application->getContainer()->query('Expiration');
804
-		$size = 0;
805
-
806
-		if ($availableSpace < 0) {
807
-			foreach ($files as $file) {
808
-				if ($availableSpace < 0 && $expiration->isExpired($file['mtime'], true)) {
809
-					$tmp = self::delete($file['name'], $user, $file['mtime']);
810
-					\OC::$server->getLogger()->info('remove "' . $file['name'] . '" (' . $tmp . 'B) to meet the limit of trash bin size (50% of available quota)', ['app' => 'files_trashbin']);
811
-					$availableSpace += $tmp;
812
-					$size += $tmp;
813
-				} else {
814
-					break;
815
-				}
816
-			}
817
-		}
818
-		return $size;
819
-	}
820
-
821
-	/**
822
-	 * delete files older then max storage time
823
-	 *
824
-	 * @param array $files list of files sorted by mtime
825
-	 * @param string $user
826
-	 * @return integer[] size of deleted files and number of deleted files
827
-	 */
828
-	public static function deleteExpiredFiles($files, $user) {
829
-		/** @var Expiration $expiration */
830
-		$expiration = \OC::$server->query(Expiration::class);
831
-		$size = 0;
832
-		$count = 0;
833
-		foreach ($files as $file) {
834
-			$timestamp = $file['mtime'];
835
-			$filename = $file['name'];
836
-			if ($expiration->isExpired($timestamp)) {
837
-				try {
838
-					$size += self::delete($filename, $user, $timestamp);
839
-					$count++;
840
-				} catch (\OCP\Files\NotPermittedException $e) {
841
-					\OC::$server->getLogger()->logException($e, ['app' => 'files_trashbin', 'level' => \OCP\ILogger::WARN, 'message' => 'Removing "' . $filename . '" from trashbin failed.']);
842
-				}
843
-				\OC::$server->getLogger()->info(
844
-					'Remove "' . $filename . '" from trashbin because it exceeds max retention obligation term.',
845
-					['app' => 'files_trashbin']
846
-				);
847
-			} else {
848
-				break;
849
-			}
850
-		}
851
-
852
-		return [$size, $count];
853
-	}
854
-
855
-	/**
856
-	 * recursive copy to copy a whole directory
857
-	 *
858
-	 * @param string $source source path, relative to the users files directory
859
-	 * @param string $destination destination path relative to the users root directoy
860
-	 * @param View $view file view for the users root directory
861
-	 * @return int
862
-	 * @throws Exceptions\CopyRecursiveException
863
-	 */
864
-	private static function copy_recursive($source, $destination, View $view) {
865
-		$size = 0;
866
-		if ($view->is_dir($source)) {
867
-			$view->mkdir($destination);
868
-			$view->touch($destination, $view->filemtime($source));
869
-			foreach ($view->getDirectoryContent($source) as $i) {
870
-				$pathDir = $source . '/' . $i['name'];
871
-				if ($view->is_dir($pathDir)) {
872
-					$size += self::copy_recursive($pathDir, $destination . '/' . $i['name'], $view);
873
-				} else {
874
-					$size += $view->filesize($pathDir);
875
-					$result = $view->copy($pathDir, $destination . '/' . $i['name']);
876
-					if (!$result) {
877
-						throw new \OCA\Files_Trashbin\Exceptions\CopyRecursiveException();
878
-					}
879
-					$view->touch($destination . '/' . $i['name'], $view->filemtime($pathDir));
880
-				}
881
-			}
882
-		} else {
883
-			$size += $view->filesize($source);
884
-			$result = $view->copy($source, $destination);
885
-			if (!$result) {
886
-				throw new \OCA\Files_Trashbin\Exceptions\CopyRecursiveException();
887
-			}
888
-			$view->touch($destination, $view->filemtime($source));
889
-		}
890
-		return $size;
891
-	}
892
-
893
-	/**
894
-	 * find all versions which belong to the file we want to restore
895
-	 *
896
-	 * @param string $filename name of the file which should be restored
897
-	 * @param int $timestamp timestamp when the file was deleted
898
-	 * @return array
899
-	 */
900
-	private static function getVersionsFromTrash($filename, $timestamp, $user) {
901
-		$view = new View('/' . $user . '/files_trashbin/versions');
902
-		$versions = [];
903
-
904
-		//force rescan of versions, local storage may not have updated the cache
905
-		if (!self::$scannedVersions) {
906
-			/** @var \OC\Files\Storage\Storage $storage */
907
-			[$storage,] = $view->resolvePath('/');
908
-			$storage->getScanner()->scan('files_trashbin/versions');
909
-			self::$scannedVersions = true;
910
-		}
911
-
912
-		if ($timestamp) {
913
-			// fetch for old versions
914
-			$matches = $view->searchRaw($filename . '.v%.d' . $timestamp);
915
-			$offset = -strlen($timestamp) - 2;
916
-		} else {
917
-			$matches = $view->searchRaw($filename . '.v%');
918
-		}
919
-
920
-		if (is_array($matches)) {
921
-			foreach ($matches as $ma) {
922
-				if ($timestamp) {
923
-					$parts = explode('.v', substr($ma['path'], 0, $offset));
924
-					$versions[] = end($parts);
925
-				} else {
926
-					$parts = explode('.v', $ma);
927
-					$versions[] = end($parts);
928
-				}
929
-			}
930
-		}
931
-		return $versions;
932
-	}
933
-
934
-	/**
935
-	 * find unique extension for restored file if a file with the same name already exists
936
-	 *
937
-	 * @param string $location where the file should be restored
938
-	 * @param string $filename name of the file
939
-	 * @param View $view filesystem view relative to users root directory
940
-	 * @return string with unique extension
941
-	 */
942
-	private static function getUniqueFilename($location, $filename, View $view) {
943
-		$ext = pathinfo($filename, PATHINFO_EXTENSION);
944
-		$name = pathinfo($filename, PATHINFO_FILENAME);
945
-		$l = \OC::$server->getL10N('files_trashbin');
946
-
947
-		$location = '/' . trim($location, '/');
948
-
949
-		// if extension is not empty we set a dot in front of it
950
-		if ($ext !== '') {
951
-			$ext = '.' . $ext;
952
-		}
953
-
954
-		if ($view->file_exists('files' . $location . '/' . $filename)) {
955
-			$i = 2;
956
-			$uniqueName = $name . " (" . $l->t("restored") . ")" . $ext;
957
-			while ($view->file_exists('files' . $location . '/' . $uniqueName)) {
958
-				$uniqueName = $name . " (" . $l->t("restored") . " " . $i . ")" . $ext;
959
-				$i++;
960
-			}
961
-
962
-			return $uniqueName;
963
-		}
964
-
965
-		return $filename;
966
-	}
967
-
968
-	/**
969
-	 * get the size from a given root folder
970
-	 *
971
-	 * @param View $view file view on the root folder
972
-	 * @return integer size of the folder
973
-	 */
974
-	private static function calculateSize($view) {
975
-		$root = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . $view->getAbsolutePath('');
976
-		if (!file_exists($root)) {
977
-			return 0;
978
-		}
979
-		$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($root), \RecursiveIteratorIterator::CHILD_FIRST);
980
-		$size = 0;
981
-
982
-		/**
983
-		 * RecursiveDirectoryIterator on an NFS path isn't iterable with foreach
984
-		 * This bug is fixed in PHP 5.5.9 or before
985
-		 * See #8376
986
-		 */
987
-		$iterator->rewind();
988
-		while ($iterator->valid()) {
989
-			$path = $iterator->current();
990
-			$relpath = substr($path, strlen($root) - 1);
991
-			if (!$view->is_dir($relpath)) {
992
-				$size += $view->filesize($relpath);
993
-			}
994
-			$iterator->next();
995
-		}
996
-		return $size;
997
-	}
998
-
999
-	/**
1000
-	 * get current size of trash bin from a given user
1001
-	 *
1002
-	 * @param string $user user who owns the trash bin
1003
-	 * @return integer trash bin size
1004
-	 */
1005
-	private static function getTrashbinSize($user) {
1006
-		$view = new View('/' . $user);
1007
-		$fileInfo = $view->getFileInfo('/files_trashbin');
1008
-		return isset($fileInfo['size']) ? $fileInfo['size'] : 0;
1009
-	}
1010
-
1011
-	/**
1012
-	 * register hooks
1013
-	 */
1014
-	public static function registerHooks() {
1015
-		// create storage wrapper on setup
1016
-		\OCP\Util::connectHook('OC_Filesystem', 'preSetup', 'OCA\Files_Trashbin\Storage', 'setupStorage');
1017
-		//Listen to delete user signal
1018
-		\OCP\Util::connectHook('OC_User', 'pre_deleteUser', 'OCA\Files_Trashbin\Hooks', 'deleteUser_hook');
1019
-		//Listen to post write hook
1020
-		\OCP\Util::connectHook('OC_Filesystem', 'post_write', 'OCA\Files_Trashbin\Hooks', 'post_write_hook');
1021
-		// pre and post-rename, disable trash logic for the copy+unlink case
1022
-		\OCP\Util::connectHook('OC_Filesystem', 'delete', 'OCA\Files_Trashbin\Trashbin', 'ensureFileScannedHook');
1023
-	}
1024
-
1025
-	/**
1026
-	 * check if trash bin is empty for a given user
1027
-	 *
1028
-	 * @param string $user
1029
-	 * @return bool
1030
-	 */
1031
-	public static function isEmpty($user) {
1032
-		$view = new View('/' . $user . '/files_trashbin');
1033
-		if ($view->is_dir('/files') && $dh = $view->opendir('/files')) {
1034
-			while ($file = readdir($dh)) {
1035
-				if (!Filesystem::isIgnoredDir($file)) {
1036
-					return false;
1037
-				}
1038
-			}
1039
-		}
1040
-		return true;
1041
-	}
1042
-
1043
-	/**
1044
-	 * @param $path
1045
-	 * @return string
1046
-	 */
1047
-	public static function preview_icon($path) {
1048
-		return \OC::$server->getURLGenerator()->linkToRoute('core_ajax_trashbin_preview', ['x' => 32, 'y' => 32, 'file' => $path]);
1049
-	}
61
+    // unit: percentage; 50% of available disk space/quota
62
+    public const DEFAULTMAXSIZE = 50;
63
+
64
+    /**
65
+     * Whether versions have already be rescanned during this PHP request
66
+     *
67
+     * @var bool
68
+     */
69
+    private static $scannedVersions = false;
70
+
71
+    /**
72
+     * Ensure we don't need to scan the file during the move to trash
73
+     * by triggering the scan in the pre-hook
74
+     *
75
+     * @param array $params
76
+     */
77
+    public static function ensureFileScannedHook($params) {
78
+        try {
79
+            self::getUidAndFilename($params['path']);
80
+        } catch (NotFoundException $e) {
81
+            // nothing to scan for non existing files
82
+        }
83
+    }
84
+
85
+    /**
86
+     * get the UID of the owner of the file and the path to the file relative to
87
+     * owners files folder
88
+     *
89
+     * @param string $filename
90
+     * @return array
91
+     * @throws \OC\User\NoUserException
92
+     */
93
+    public static function getUidAndFilename($filename) {
94
+        $uid = Filesystem::getOwner($filename);
95
+        $userManager = \OC::$server->getUserManager();
96
+        // if the user with the UID doesn't exists, e.g. because the UID points
97
+        // to a remote user with a federated cloud ID we use the current logged-in
98
+        // user. We need a valid local user to move the file to the right trash bin
99
+        if (!$userManager->userExists($uid)) {
100
+            $uid = User::getUser();
101
+        }
102
+        if (!$uid) {
103
+            // no owner, usually because of share link from ext storage
104
+            return [null, null];
105
+        }
106
+        Filesystem::initMountPoints($uid);
107
+        if ($uid !== User::getUser()) {
108
+            $info = Filesystem::getFileInfo($filename);
109
+            $ownerView = new View('/' . $uid . '/files');
110
+            try {
111
+                $filename = $ownerView->getPath($info['fileid']);
112
+            } catch (NotFoundException $e) {
113
+                $filename = null;
114
+            }
115
+        }
116
+        return [$uid, $filename];
117
+    }
118
+
119
+    /**
120
+     * get original location of files for user
121
+     *
122
+     * @param string $user
123
+     * @return array (filename => array (timestamp => original location))
124
+     */
125
+    public static function getLocations($user) {
126
+        $query = \OC_DB::prepare('SELECT `id`, `timestamp`, `location`'
127
+            . ' FROM `*PREFIX*files_trash` WHERE `user`=?');
128
+        $result = $query->execute([$user]);
129
+        $array = [];
130
+        while ($row = $result->fetchRow()) {
131
+            if (isset($array[$row['id']])) {
132
+                $array[$row['id']][$row['timestamp']] = $row['location'];
133
+            } else {
134
+                $array[$row['id']] = [$row['timestamp'] => $row['location']];
135
+            }
136
+        }
137
+        return $array;
138
+    }
139
+
140
+    /**
141
+     * get original location of file
142
+     *
143
+     * @param string $user
144
+     * @param string $filename
145
+     * @param string $timestamp
146
+     * @return string original location
147
+     */
148
+    public static function getLocation($user, $filename, $timestamp) {
149
+        $query = \OC_DB::prepare('SELECT `location` FROM `*PREFIX*files_trash`'
150
+            . ' WHERE `user`=? AND `id`=? AND `timestamp`=?');
151
+        $result = $query->execute([$user, $filename, $timestamp])->fetchAll();
152
+        if (isset($result[0]['location'])) {
153
+            return $result[0]['location'];
154
+        } else {
155
+            return false;
156
+        }
157
+    }
158
+
159
+    private static function setUpTrash($user) {
160
+        $view = new View('/' . $user);
161
+        if (!$view->is_dir('files_trashbin')) {
162
+            $view->mkdir('files_trashbin');
163
+        }
164
+        if (!$view->is_dir('files_trashbin/files')) {
165
+            $view->mkdir('files_trashbin/files');
166
+        }
167
+        if (!$view->is_dir('files_trashbin/versions')) {
168
+            $view->mkdir('files_trashbin/versions');
169
+        }
170
+        if (!$view->is_dir('files_trashbin/keys')) {
171
+            $view->mkdir('files_trashbin/keys');
172
+        }
173
+    }
174
+
175
+
176
+    /**
177
+     * copy file to owners trash
178
+     *
179
+     * @param string $sourcePath
180
+     * @param string $owner
181
+     * @param string $targetPath
182
+     * @param $user
183
+     * @param integer $timestamp
184
+     */
185
+    private static function copyFilesToUser($sourcePath, $owner, $targetPath, $user, $timestamp) {
186
+        self::setUpTrash($owner);
187
+
188
+        $targetFilename = basename($targetPath);
189
+        $targetLocation = dirname($targetPath);
190
+
191
+        $sourceFilename = basename($sourcePath);
192
+
193
+        $view = new View('/');
194
+
195
+        $target = $user . '/files_trashbin/files/' . $targetFilename . '.d' . $timestamp;
196
+        $source = $owner . '/files_trashbin/files/' . $sourceFilename . '.d' . $timestamp;
197
+        $free = $view->free_space($target);
198
+        $isUnknownOrUnlimitedFreeSpace = $free < 0;
199
+        $isEnoughFreeSpaceLeft = $view->filesize($source) < $free;
200
+        if ($isUnknownOrUnlimitedFreeSpace || $isEnoughFreeSpaceLeft) {
201
+            self::copy_recursive($source, $target, $view);
202
+        }
203
+
204
+
205
+        if ($view->file_exists($target)) {
206
+            $query = \OC_DB::prepare("INSERT INTO `*PREFIX*files_trash` (`id`,`timestamp`,`location`,`user`) VALUES (?,?,?,?)");
207
+            $result = $query->execute([$targetFilename, $timestamp, $targetLocation, $user]);
208
+            if (!$result) {
209
+                \OC::$server->getLogger()->error('trash bin database couldn\'t be updated for the files owner', ['app' => 'files_trashbin']);
210
+            }
211
+        }
212
+    }
213
+
214
+
215
+    /**
216
+     * move file to the trash bin
217
+     *
218
+     * @param string $file_path path to the deleted file/directory relative to the files root directory
219
+     * @param bool $ownerOnly delete for owner only (if file gets moved out of a shared folder)
220
+     *
221
+     * @return bool
222
+     */
223
+    public static function move2trash($file_path, $ownerOnly = false) {
224
+        // get the user for which the filesystem is setup
225
+        $root = Filesystem::getRoot();
226
+        [, $user] = explode('/', $root);
227
+        [$owner, $ownerPath] = self::getUidAndFilename($file_path);
228
+
229
+        // if no owner found (ex: ext storage + share link), will use the current user's trashbin then
230
+        if (is_null($owner)) {
231
+            $owner = $user;
232
+            $ownerPath = $file_path;
233
+        }
234
+
235
+        $ownerView = new View('/' . $owner);
236
+        // file has been deleted in between
237
+        if (is_null($ownerPath) || $ownerPath === '' || !$ownerView->file_exists('/files/' . $ownerPath)) {
238
+            return true;
239
+        }
240
+
241
+        self::setUpTrash($user);
242
+        if ($owner !== $user) {
243
+            // also setup for owner
244
+            self::setUpTrash($owner);
245
+        }
246
+
247
+        $path_parts = pathinfo($ownerPath);
248
+
249
+        $filename = $path_parts['basename'];
250
+        $location = $path_parts['dirname'];
251
+        /** @var ITimeFactory $timeFactory */
252
+        $timeFactory = \OC::$server->query(ITimeFactory::class);
253
+        $timestamp = $timeFactory->getTime();
254
+
255
+        $lockingProvider = \OC::$server->getLockingProvider();
256
+
257
+        // disable proxy to prevent recursive calls
258
+        $trashPath = '/files_trashbin/files/' . $filename . '.d' . $timestamp;
259
+        $gotLock = false;
260
+
261
+        while (!$gotLock) {
262
+            try {
263
+                /** @var \OC\Files\Storage\Storage $trashStorage */
264
+                [$trashStorage, $trashInternalPath] = $ownerView->resolvePath($trashPath);
265
+
266
+                $trashStorage->acquireLock($trashInternalPath, ILockingProvider::LOCK_EXCLUSIVE, $lockingProvider);
267
+                $gotLock = true;
268
+            } catch (LockedException $e) {
269
+                // a file with the same name is being deleted concurrently
270
+                // nudge the timestamp a bit to resolve the conflict
271
+
272
+                $timestamp = $timestamp + 1;
273
+
274
+                $trashPath = '/files_trashbin/files/' . $filename . '.d' . $timestamp;
275
+            }
276
+        }
277
+
278
+        /** @var \OC\Files\Storage\Storage $sourceStorage */
279
+        [$sourceStorage, $sourceInternalPath] = $ownerView->resolvePath('/files/' . $ownerPath);
280
+
281
+        try {
282
+            $moveSuccessful = true;
283
+            if ($trashStorage->file_exists($trashInternalPath)) {
284
+                $trashStorage->unlink($trashInternalPath);
285
+            }
286
+            $trashStorage->moveFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
287
+        } catch (\OCA\Files_Trashbin\Exceptions\CopyRecursiveException $e) {
288
+            $moveSuccessful = false;
289
+            if ($trashStorage->file_exists($trashInternalPath)) {
290
+                $trashStorage->unlink($trashInternalPath);
291
+            }
292
+            \OC::$server->getLogger()->error('Couldn\'t move ' . $file_path . ' to the trash bin', ['app' => 'files_trashbin']);
293
+        }
294
+
295
+        if ($sourceStorage->file_exists($sourceInternalPath)) { // failed to delete the original file, abort
296
+            if ($sourceStorage->is_dir($sourceInternalPath)) {
297
+                $sourceStorage->rmdir($sourceInternalPath);
298
+            } else {
299
+                $sourceStorage->unlink($sourceInternalPath);
300
+            }
301
+            return false;
302
+        }
303
+
304
+        $trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
305
+
306
+        if ($moveSuccessful) {
307
+            $query = \OC_DB::prepare("INSERT INTO `*PREFIX*files_trash` (`id`,`timestamp`,`location`,`user`) VALUES (?,?,?,?)");
308
+            $result = $query->execute([$filename, $timestamp, $location, $owner]);
309
+            if (!$result) {
310
+                \OC::$server->getLogger()->error('trash bin database couldn\'t be updated', ['app' => 'files_trashbin']);
311
+            }
312
+            \OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_moveToTrash', ['filePath' => Filesystem::normalizePath($file_path),
313
+                'trashPath' => Filesystem::normalizePath($filename . '.d' . $timestamp)]);
314
+
315
+            self::retainVersions($filename, $owner, $ownerPath, $timestamp);
316
+
317
+            // if owner !== user we need to also add a copy to the users trash
318
+            if ($user !== $owner && $ownerOnly === false) {
319
+                self::copyFilesToUser($ownerPath, $owner, $file_path, $user, $timestamp);
320
+            }
321
+        }
322
+
323
+        $trashStorage->releaseLock($trashInternalPath, ILockingProvider::LOCK_EXCLUSIVE, $lockingProvider);
324
+
325
+        self::scheduleExpire($user);
326
+
327
+        // if owner !== user we also need to update the owners trash size
328
+        if ($owner !== $user) {
329
+            self::scheduleExpire($owner);
330
+        }
331
+
332
+        return $moveSuccessful;
333
+    }
334
+
335
+    /**
336
+     * Move file versions to trash so that they can be restored later
337
+     *
338
+     * @param string $filename of deleted file
339
+     * @param string $owner owner user id
340
+     * @param string $ownerPath path relative to the owner's home storage
341
+     * @param integer $timestamp when the file was deleted
342
+     */
343
+    private static function retainVersions($filename, $owner, $ownerPath, $timestamp) {
344
+        if (\OCP\App::isEnabled('files_versions') && !empty($ownerPath)) {
345
+            $user = User::getUser();
346
+            $rootView = new View('/');
347
+
348
+            if ($rootView->is_dir($owner . '/files_versions/' . $ownerPath)) {
349
+                if ($owner !== $user) {
350
+                    self::copy_recursive($owner . '/files_versions/' . $ownerPath, $owner . '/files_trashbin/versions/' . basename($ownerPath) . '.d' . $timestamp, $rootView);
351
+                }
352
+                self::move($rootView, $owner . '/files_versions/' . $ownerPath, $user . '/files_trashbin/versions/' . $filename . '.d' . $timestamp);
353
+            } elseif ($versions = \OCA\Files_Versions\Storage::getVersions($owner, $ownerPath)) {
354
+                foreach ($versions as $v) {
355
+                    if ($owner !== $user) {
356
+                        self::copy($rootView, $owner . '/files_versions' . $v['path'] . '.v' . $v['version'], $owner . '/files_trashbin/versions/' . $v['name'] . '.v' . $v['version'] . '.d' . $timestamp);
357
+                    }
358
+                    self::move($rootView, $owner . '/files_versions' . $v['path'] . '.v' . $v['version'], $user . '/files_trashbin/versions/' . $filename . '.v' . $v['version'] . '.d' . $timestamp);
359
+                }
360
+            }
361
+        }
362
+    }
363
+
364
+    /**
365
+     * Move a file or folder on storage level
366
+     *
367
+     * @param View $view
368
+     * @param string $source
369
+     * @param string $target
370
+     * @return bool
371
+     */
372
+    private static function move(View $view, $source, $target) {
373
+        /** @var \OC\Files\Storage\Storage $sourceStorage */
374
+        [$sourceStorage, $sourceInternalPath] = $view->resolvePath($source);
375
+        /** @var \OC\Files\Storage\Storage $targetStorage */
376
+        [$targetStorage, $targetInternalPath] = $view->resolvePath($target);
377
+        /** @var \OC\Files\Storage\Storage $ownerTrashStorage */
378
+
379
+        $result = $targetStorage->moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
380
+        if ($result) {
381
+            $targetStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
382
+        }
383
+        return $result;
384
+    }
385
+
386
+    /**
387
+     * Copy a file or folder on storage level
388
+     *
389
+     * @param View $view
390
+     * @param string $source
391
+     * @param string $target
392
+     * @return bool
393
+     */
394
+    private static function copy(View $view, $source, $target) {
395
+        /** @var \OC\Files\Storage\Storage $sourceStorage */
396
+        [$sourceStorage, $sourceInternalPath] = $view->resolvePath($source);
397
+        /** @var \OC\Files\Storage\Storage $targetStorage */
398
+        [$targetStorage, $targetInternalPath] = $view->resolvePath($target);
399
+        /** @var \OC\Files\Storage\Storage $ownerTrashStorage */
400
+
401
+        $result = $targetStorage->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
402
+        if ($result) {
403
+            $targetStorage->getUpdater()->update($targetInternalPath);
404
+        }
405
+        return $result;
406
+    }
407
+
408
+    /**
409
+     * Restore a file or folder from trash bin
410
+     *
411
+     * @param string $file path to the deleted file/folder relative to "files_trashbin/files/",
412
+     * including the timestamp suffix ".d12345678"
413
+     * @param string $filename name of the file/folder
414
+     * @param int $timestamp time when the file/folder was deleted
415
+     *
416
+     * @return bool true on success, false otherwise
417
+     */
418
+    public static function restore($file, $filename, $timestamp) {
419
+        $user = User::getUser();
420
+        $view = new View('/' . $user);
421
+
422
+        $location = '';
423
+        if ($timestamp) {
424
+            $location = self::getLocation($user, $filename, $timestamp);
425
+            if ($location === false) {
426
+                \OC::$server->getLogger()->error('trash bin database inconsistent! ($user: ' . $user . ' $filename: ' . $filename . ', $timestamp: ' . $timestamp . ')', ['app' => 'files_trashbin']);
427
+            } else {
428
+                // if location no longer exists, restore file in the root directory
429
+                if ($location !== '/' &&
430
+                    (!$view->is_dir('files/' . $location) ||
431
+                        !$view->isCreatable('files/' . $location))
432
+                ) {
433
+                    $location = '';
434
+                }
435
+            }
436
+        }
437
+
438
+        // we need a  extension in case a file/dir with the same name already exists
439
+        $uniqueFilename = self::getUniqueFilename($location, $filename, $view);
440
+
441
+        $source = Filesystem::normalizePath('files_trashbin/files/' . $file);
442
+        $target = Filesystem::normalizePath('files/' . $location . '/' . $uniqueFilename);
443
+        if (!$view->file_exists($source)) {
444
+            return false;
445
+        }
446
+        $mtime = $view->filemtime($source);
447
+
448
+        // restore file
449
+        if (!$view->isCreatable(dirname($target))) {
450
+            throw new NotPermittedException("Can't restore trash item because the target folder is not writable");
451
+        }
452
+        $restoreResult = $view->rename($source, $target);
453
+
454
+        // handle the restore result
455
+        if ($restoreResult) {
456
+            $fakeRoot = $view->getRoot();
457
+            $view->chroot('/' . $user . '/files');
458
+            $view->touch('/' . $location . '/' . $uniqueFilename, $mtime);
459
+            $view->chroot($fakeRoot);
460
+            \OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', ['filePath' => Filesystem::normalizePath('/' . $location . '/' . $uniqueFilename),
461
+                'trashPath' => Filesystem::normalizePath($file)]);
462
+
463
+            self::restoreVersions($view, $file, $filename, $uniqueFilename, $location, $timestamp);
464
+
465
+            if ($timestamp) {
466
+                $query = \OC_DB::prepare('DELETE FROM `*PREFIX*files_trash` WHERE `user`=? AND `id`=? AND `timestamp`=?');
467
+                $query->execute([$user, $filename, $timestamp]);
468
+            }
469
+
470
+            return true;
471
+        }
472
+
473
+        return false;
474
+    }
475
+
476
+    /**
477
+     * restore versions from trash bin
478
+     *
479
+     * @param View $view file view
480
+     * @param string $file complete path to file
481
+     * @param string $filename name of file once it was deleted
482
+     * @param string $uniqueFilename new file name to restore the file without overwriting existing files
483
+     * @param string $location location if file
484
+     * @param int $timestamp deletion time
485
+     * @return false|null
486
+     */
487
+    private static function restoreVersions(View $view, $file, $filename, $uniqueFilename, $location, $timestamp) {
488
+        if (\OCP\App::isEnabled('files_versions')) {
489
+            $user = User::getUser();
490
+            $rootView = new View('/');
491
+
492
+            $target = Filesystem::normalizePath('/' . $location . '/' . $uniqueFilename);
493
+
494
+            [$owner, $ownerPath] = self::getUidAndFilename($target);
495
+
496
+            // file has been deleted in between
497
+            if (empty($ownerPath)) {
498
+                return false;
499
+            }
500
+
501
+            if ($timestamp) {
502
+                $versionedFile = $filename;
503
+            } else {
504
+                $versionedFile = $file;
505
+            }
506
+
507
+            if ($view->is_dir('/files_trashbin/versions/' . $file)) {
508
+                $rootView->rename(Filesystem::normalizePath($user . '/files_trashbin/versions/' . $file), Filesystem::normalizePath($owner . '/files_versions/' . $ownerPath));
509
+            } elseif ($versions = self::getVersionsFromTrash($versionedFile, $timestamp, $user)) {
510
+                foreach ($versions as $v) {
511
+                    if ($timestamp) {
512
+                        $rootView->rename($user . '/files_trashbin/versions/' . $versionedFile . '.v' . $v . '.d' . $timestamp, $owner . '/files_versions/' . $ownerPath . '.v' . $v);
513
+                    } else {
514
+                        $rootView->rename($user . '/files_trashbin/versions/' . $versionedFile . '.v' . $v, $owner . '/files_versions/' . $ownerPath . '.v' . $v);
515
+                    }
516
+                }
517
+            }
518
+        }
519
+    }
520
+
521
+    /**
522
+     * delete all files from the trash
523
+     */
524
+    public static function deleteAll() {
525
+        $user = User::getUser();
526
+        $userRoot = \OC::$server->getUserFolder($user)->getParent();
527
+        $view = new View('/' . $user);
528
+        $fileInfos = $view->getDirectoryContent('files_trashbin/files');
529
+
530
+        try {
531
+            $trash = $userRoot->get('files_trashbin');
532
+        } catch (NotFoundException $e) {
533
+            return false;
534
+        }
535
+
536
+        // Array to store the relative path in (after the file is deleted, the view won't be able to relativise the path anymore)
537
+        $filePaths = [];
538
+        foreach ($fileInfos as $fileInfo) {
539
+            $filePaths[] = $view->getRelativePath($fileInfo->getPath());
540
+        }
541
+        unset($fileInfos); // save memory
542
+
543
+        // Bulk PreDelete-Hook
544
+        \OC_Hook::emit('\OCP\Trashbin', 'preDeleteAll', ['paths' => $filePaths]);
545
+
546
+        // Single-File Hooks
547
+        foreach ($filePaths as $path) {
548
+            self::emitTrashbinPreDelete($path);
549
+        }
550
+
551
+        // actual file deletion
552
+        $trash->delete();
553
+        $query = \OC_DB::prepare('DELETE FROM `*PREFIX*files_trash` WHERE `user`=?');
554
+        $query->execute([$user]);
555
+
556
+        // Bulk PostDelete-Hook
557
+        \OC_Hook::emit('\OCP\Trashbin', 'deleteAll', ['paths' => $filePaths]);
558
+
559
+        // Single-File Hooks
560
+        foreach ($filePaths as $path) {
561
+            self::emitTrashbinPostDelete($path);
562
+        }
563
+
564
+        $trash = $userRoot->newFolder('files_trashbin');
565
+        $trash->newFolder('files');
566
+
567
+        return true;
568
+    }
569
+
570
+    /**
571
+     * wrapper function to emit the 'preDelete' hook of \OCP\Trashbin before a file is deleted
572
+     *
573
+     * @param string $path
574
+     */
575
+    protected static function emitTrashbinPreDelete($path) {
576
+        \OC_Hook::emit('\OCP\Trashbin', 'preDelete', ['path' => $path]);
577
+    }
578
+
579
+    /**
580
+     * wrapper function to emit the 'delete' hook of \OCP\Trashbin after a file has been deleted
581
+     *
582
+     * @param string $path
583
+     */
584
+    protected static function emitTrashbinPostDelete($path) {
585
+        \OC_Hook::emit('\OCP\Trashbin', 'delete', ['path' => $path]);
586
+    }
587
+
588
+    /**
589
+     * delete file from trash bin permanently
590
+     *
591
+     * @param string $filename path to the file
592
+     * @param string $user
593
+     * @param int $timestamp of deletion time
594
+     *
595
+     * @return int size of deleted files
596
+     */
597
+    public static function delete($filename, $user, $timestamp = null) {
598
+        $userRoot = \OC::$server->getUserFolder($user)->getParent();
599
+        $view = new View('/' . $user);
600
+        $size = 0;
601
+
602
+        if ($timestamp) {
603
+            $query = \OC_DB::prepare('DELETE FROM `*PREFIX*files_trash` WHERE `user`=? AND `id`=? AND `timestamp`=?');
604
+            $query->execute([$user, $filename, $timestamp]);
605
+            $file = $filename . '.d' . $timestamp;
606
+        } else {
607
+            $file = $filename;
608
+        }
609
+
610
+        $size += self::deleteVersions($view, $file, $filename, $timestamp, $user);
611
+
612
+        try {
613
+            $node = $userRoot->get('/files_trashbin/files/' . $file);
614
+        } catch (NotFoundException $e) {
615
+            return $size;
616
+        }
617
+
618
+        if ($node instanceof Folder) {
619
+            $size += self::calculateSize(new View('/' . $user . '/files_trashbin/files/' . $file));
620
+        } elseif ($node instanceof File) {
621
+            $size += $view->filesize('/files_trashbin/files/' . $file);
622
+        }
623
+
624
+        self::emitTrashbinPreDelete('/files_trashbin/files/' . $file);
625
+        $node->delete();
626
+        self::emitTrashbinPostDelete('/files_trashbin/files/' . $file);
627
+
628
+        return $size;
629
+    }
630
+
631
+    /**
632
+     * @param View $view
633
+     * @param string $file
634
+     * @param string $filename
635
+     * @param integer|null $timestamp
636
+     * @param string $user
637
+     * @return int
638
+     */
639
+    private static function deleteVersions(View $view, $file, $filename, $timestamp, $user) {
640
+        $size = 0;
641
+        if (\OCP\App::isEnabled('files_versions')) {
642
+            if ($view->is_dir('files_trashbin/versions/' . $file)) {
643
+                $size += self::calculateSize(new View('/' . $user . '/files_trashbin/versions/' . $file));
644
+                $view->unlink('files_trashbin/versions/' . $file);
645
+            } elseif ($versions = self::getVersionsFromTrash($filename, $timestamp, $user)) {
646
+                foreach ($versions as $v) {
647
+                    if ($timestamp) {
648
+                        $size += $view->filesize('/files_trashbin/versions/' . $filename . '.v' . $v . '.d' . $timestamp);
649
+                        $view->unlink('/files_trashbin/versions/' . $filename . '.v' . $v . '.d' . $timestamp);
650
+                    } else {
651
+                        $size += $view->filesize('/files_trashbin/versions/' . $filename . '.v' . $v);
652
+                        $view->unlink('/files_trashbin/versions/' . $filename . '.v' . $v);
653
+                    }
654
+                }
655
+            }
656
+        }
657
+        return $size;
658
+    }
659
+
660
+    /**
661
+     * check to see whether a file exists in trashbin
662
+     *
663
+     * @param string $filename path to the file
664
+     * @param int $timestamp of deletion time
665
+     * @return bool true if file exists, otherwise false
666
+     */
667
+    public static function file_exists($filename, $timestamp = null) {
668
+        $user = User::getUser();
669
+        $view = new View('/' . $user);
670
+
671
+        if ($timestamp) {
672
+            $filename = $filename . '.d' . $timestamp;
673
+        }
674
+
675
+        $target = Filesystem::normalizePath('files_trashbin/files/' . $filename);
676
+        return $view->file_exists($target);
677
+    }
678
+
679
+    /**
680
+     * deletes used space for trash bin in db if user was deleted
681
+     *
682
+     * @param string $uid id of deleted user
683
+     * @return bool result of db delete operation
684
+     */
685
+    public static function deleteUser($uid) {
686
+        $query = \OC_DB::prepare('DELETE FROM `*PREFIX*files_trash` WHERE `user`=?');
687
+        return $query->execute([$uid]);
688
+    }
689
+
690
+    /**
691
+     * calculate remaining free space for trash bin
692
+     *
693
+     * @param integer $trashbinSize current size of the trash bin
694
+     * @param string $user
695
+     * @return int available free space for trash bin
696
+     */
697
+    private static function calculateFreeSpace($trashbinSize, $user) {
698
+        $config = \OC::$server->getConfig();
699
+        $systemTrashbinSize = (int)$config->getAppValue('files_trashbin', 'trashbin_size', '-1');
700
+        $userTrashbinSize = (int)$config->getUserValue($user, 'files_trashbin', 'trashbin_size', '-1');
701
+        $configuredTrashbinSize = ($userTrashbinSize < 0) ? $systemTrashbinSize : $userTrashbinSize;
702
+        if ($configuredTrashbinSize) {
703
+            return $configuredTrashbinSize - $trashbinSize;
704
+        }
705
+
706
+        $softQuota = true;
707
+        $userObject = \OC::$server->getUserManager()->get($user);
708
+        if (is_null($userObject)) {
709
+            return 0;
710
+        }
711
+        $quota = $userObject->getQuota();
712
+        if ($quota === null || $quota === 'none') {
713
+            $quota = Filesystem::free_space('/');
714
+            $softQuota = false;
715
+            // inf or unknown free space
716
+            if ($quota < 0) {
717
+                $quota = PHP_INT_MAX;
718
+            }
719
+        } else {
720
+            $quota = \OCP\Util::computerFileSize($quota);
721
+        }
722
+
723
+        // calculate available space for trash bin
724
+        // subtract size of files and current trash bin size from quota
725
+        if ($softQuota) {
726
+            $userFolder = \OC::$server->getUserFolder($user);
727
+            if (is_null($userFolder)) {
728
+                return 0;
729
+            }
730
+            $free = $quota - $userFolder->getSize(false); // remaining free space for user
731
+            if ($free > 0) {
732
+                $availableSpace = ($free * self::DEFAULTMAXSIZE / 100) - $trashbinSize; // how much space can be used for versions
733
+            } else {
734
+                $availableSpace = $free - $trashbinSize;
735
+            }
736
+        } else {
737
+            $availableSpace = $quota;
738
+        }
739
+
740
+        return $availableSpace;
741
+    }
742
+
743
+    /**
744
+     * resize trash bin if necessary after a new file was added to Nextcloud
745
+     *
746
+     * @param string $user user id
747
+     */
748
+    public static function resizeTrash($user) {
749
+        $size = self::getTrashbinSize($user);
750
+
751
+        $freeSpace = self::calculateFreeSpace($size, $user);
752
+
753
+        if ($freeSpace < 0) {
754
+            self::scheduleExpire($user);
755
+        }
756
+    }
757
+
758
+    /**
759
+     * clean up the trash bin
760
+     *
761
+     * @param string $user
762
+     */
763
+    public static function expire($user) {
764
+        $trashBinSize = self::getTrashbinSize($user);
765
+        $availableSpace = self::calculateFreeSpace($trashBinSize, $user);
766
+
767
+        $dirContent = Helper::getTrashFiles('/', $user, 'mtime');
768
+
769
+        // delete all files older then $retention_obligation
770
+        [$delSize, $count] = self::deleteExpiredFiles($dirContent, $user);
771
+
772
+        $availableSpace += $delSize;
773
+
774
+        // delete files from trash until we meet the trash bin size limit again
775
+        self::deleteFiles(array_slice($dirContent, $count), $user, $availableSpace);
776
+    }
777
+
778
+    /**
779
+     * @param string $user
780
+     */
781
+    private static function scheduleExpire($user) {
782
+        // let the admin disable auto expire
783
+        /** @var Application $application */
784
+        $application = \OC::$server->query(Application::class);
785
+        $expiration = $application->getContainer()->query('Expiration');
786
+        if ($expiration->isEnabled()) {
787
+            \OC::$server->getCommandBus()->push(new Expire($user));
788
+        }
789
+    }
790
+
791
+    /**
792
+     * if the size limit for the trash bin is reached, we delete the oldest
793
+     * files in the trash bin until we meet the limit again
794
+     *
795
+     * @param array $files
796
+     * @param string $user
797
+     * @param int $availableSpace available disc space
798
+     * @return int size of deleted files
799
+     */
800
+    protected static function deleteFiles($files, $user, $availableSpace) {
801
+        /** @var Application $application */
802
+        $application = \OC::$server->query(Application::class);
803
+        $expiration = $application->getContainer()->query('Expiration');
804
+        $size = 0;
805
+
806
+        if ($availableSpace < 0) {
807
+            foreach ($files as $file) {
808
+                if ($availableSpace < 0 && $expiration->isExpired($file['mtime'], true)) {
809
+                    $tmp = self::delete($file['name'], $user, $file['mtime']);
810
+                    \OC::$server->getLogger()->info('remove "' . $file['name'] . '" (' . $tmp . 'B) to meet the limit of trash bin size (50% of available quota)', ['app' => 'files_trashbin']);
811
+                    $availableSpace += $tmp;
812
+                    $size += $tmp;
813
+                } else {
814
+                    break;
815
+                }
816
+            }
817
+        }
818
+        return $size;
819
+    }
820
+
821
+    /**
822
+     * delete files older then max storage time
823
+     *
824
+     * @param array $files list of files sorted by mtime
825
+     * @param string $user
826
+     * @return integer[] size of deleted files and number of deleted files
827
+     */
828
+    public static function deleteExpiredFiles($files, $user) {
829
+        /** @var Expiration $expiration */
830
+        $expiration = \OC::$server->query(Expiration::class);
831
+        $size = 0;
832
+        $count = 0;
833
+        foreach ($files as $file) {
834
+            $timestamp = $file['mtime'];
835
+            $filename = $file['name'];
836
+            if ($expiration->isExpired($timestamp)) {
837
+                try {
838
+                    $size += self::delete($filename, $user, $timestamp);
839
+                    $count++;
840
+                } catch (\OCP\Files\NotPermittedException $e) {
841
+                    \OC::$server->getLogger()->logException($e, ['app' => 'files_trashbin', 'level' => \OCP\ILogger::WARN, 'message' => 'Removing "' . $filename . '" from trashbin failed.']);
842
+                }
843
+                \OC::$server->getLogger()->info(
844
+                    'Remove "' . $filename . '" from trashbin because it exceeds max retention obligation term.',
845
+                    ['app' => 'files_trashbin']
846
+                );
847
+            } else {
848
+                break;
849
+            }
850
+        }
851
+
852
+        return [$size, $count];
853
+    }
854
+
855
+    /**
856
+     * recursive copy to copy a whole directory
857
+     *
858
+     * @param string $source source path, relative to the users files directory
859
+     * @param string $destination destination path relative to the users root directoy
860
+     * @param View $view file view for the users root directory
861
+     * @return int
862
+     * @throws Exceptions\CopyRecursiveException
863
+     */
864
+    private static function copy_recursive($source, $destination, View $view) {
865
+        $size = 0;
866
+        if ($view->is_dir($source)) {
867
+            $view->mkdir($destination);
868
+            $view->touch($destination, $view->filemtime($source));
869
+            foreach ($view->getDirectoryContent($source) as $i) {
870
+                $pathDir = $source . '/' . $i['name'];
871
+                if ($view->is_dir($pathDir)) {
872
+                    $size += self::copy_recursive($pathDir, $destination . '/' . $i['name'], $view);
873
+                } else {
874
+                    $size += $view->filesize($pathDir);
875
+                    $result = $view->copy($pathDir, $destination . '/' . $i['name']);
876
+                    if (!$result) {
877
+                        throw new \OCA\Files_Trashbin\Exceptions\CopyRecursiveException();
878
+                    }
879
+                    $view->touch($destination . '/' . $i['name'], $view->filemtime($pathDir));
880
+                }
881
+            }
882
+        } else {
883
+            $size += $view->filesize($source);
884
+            $result = $view->copy($source, $destination);
885
+            if (!$result) {
886
+                throw new \OCA\Files_Trashbin\Exceptions\CopyRecursiveException();
887
+            }
888
+            $view->touch($destination, $view->filemtime($source));
889
+        }
890
+        return $size;
891
+    }
892
+
893
+    /**
894
+     * find all versions which belong to the file we want to restore
895
+     *
896
+     * @param string $filename name of the file which should be restored
897
+     * @param int $timestamp timestamp when the file was deleted
898
+     * @return array
899
+     */
900
+    private static function getVersionsFromTrash($filename, $timestamp, $user) {
901
+        $view = new View('/' . $user . '/files_trashbin/versions');
902
+        $versions = [];
903
+
904
+        //force rescan of versions, local storage may not have updated the cache
905
+        if (!self::$scannedVersions) {
906
+            /** @var \OC\Files\Storage\Storage $storage */
907
+            [$storage,] = $view->resolvePath('/');
908
+            $storage->getScanner()->scan('files_trashbin/versions');
909
+            self::$scannedVersions = true;
910
+        }
911
+
912
+        if ($timestamp) {
913
+            // fetch for old versions
914
+            $matches = $view->searchRaw($filename . '.v%.d' . $timestamp);
915
+            $offset = -strlen($timestamp) - 2;
916
+        } else {
917
+            $matches = $view->searchRaw($filename . '.v%');
918
+        }
919
+
920
+        if (is_array($matches)) {
921
+            foreach ($matches as $ma) {
922
+                if ($timestamp) {
923
+                    $parts = explode('.v', substr($ma['path'], 0, $offset));
924
+                    $versions[] = end($parts);
925
+                } else {
926
+                    $parts = explode('.v', $ma);
927
+                    $versions[] = end($parts);
928
+                }
929
+            }
930
+        }
931
+        return $versions;
932
+    }
933
+
934
+    /**
935
+     * find unique extension for restored file if a file with the same name already exists
936
+     *
937
+     * @param string $location where the file should be restored
938
+     * @param string $filename name of the file
939
+     * @param View $view filesystem view relative to users root directory
940
+     * @return string with unique extension
941
+     */
942
+    private static function getUniqueFilename($location, $filename, View $view) {
943
+        $ext = pathinfo($filename, PATHINFO_EXTENSION);
944
+        $name = pathinfo($filename, PATHINFO_FILENAME);
945
+        $l = \OC::$server->getL10N('files_trashbin');
946
+
947
+        $location = '/' . trim($location, '/');
948
+
949
+        // if extension is not empty we set a dot in front of it
950
+        if ($ext !== '') {
951
+            $ext = '.' . $ext;
952
+        }
953
+
954
+        if ($view->file_exists('files' . $location . '/' . $filename)) {
955
+            $i = 2;
956
+            $uniqueName = $name . " (" . $l->t("restored") . ")" . $ext;
957
+            while ($view->file_exists('files' . $location . '/' . $uniqueName)) {
958
+                $uniqueName = $name . " (" . $l->t("restored") . " " . $i . ")" . $ext;
959
+                $i++;
960
+            }
961
+
962
+            return $uniqueName;
963
+        }
964
+
965
+        return $filename;
966
+    }
967
+
968
+    /**
969
+     * get the size from a given root folder
970
+     *
971
+     * @param View $view file view on the root folder
972
+     * @return integer size of the folder
973
+     */
974
+    private static function calculateSize($view) {
975
+        $root = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . $view->getAbsolutePath('');
976
+        if (!file_exists($root)) {
977
+            return 0;
978
+        }
979
+        $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($root), \RecursiveIteratorIterator::CHILD_FIRST);
980
+        $size = 0;
981
+
982
+        /**
983
+         * RecursiveDirectoryIterator on an NFS path isn't iterable with foreach
984
+         * This bug is fixed in PHP 5.5.9 or before
985
+         * See #8376
986
+         */
987
+        $iterator->rewind();
988
+        while ($iterator->valid()) {
989
+            $path = $iterator->current();
990
+            $relpath = substr($path, strlen($root) - 1);
991
+            if (!$view->is_dir($relpath)) {
992
+                $size += $view->filesize($relpath);
993
+            }
994
+            $iterator->next();
995
+        }
996
+        return $size;
997
+    }
998
+
999
+    /**
1000
+     * get current size of trash bin from a given user
1001
+     *
1002
+     * @param string $user user who owns the trash bin
1003
+     * @return integer trash bin size
1004
+     */
1005
+    private static function getTrashbinSize($user) {
1006
+        $view = new View('/' . $user);
1007
+        $fileInfo = $view->getFileInfo('/files_trashbin');
1008
+        return isset($fileInfo['size']) ? $fileInfo['size'] : 0;
1009
+    }
1010
+
1011
+    /**
1012
+     * register hooks
1013
+     */
1014
+    public static function registerHooks() {
1015
+        // create storage wrapper on setup
1016
+        \OCP\Util::connectHook('OC_Filesystem', 'preSetup', 'OCA\Files_Trashbin\Storage', 'setupStorage');
1017
+        //Listen to delete user signal
1018
+        \OCP\Util::connectHook('OC_User', 'pre_deleteUser', 'OCA\Files_Trashbin\Hooks', 'deleteUser_hook');
1019
+        //Listen to post write hook
1020
+        \OCP\Util::connectHook('OC_Filesystem', 'post_write', 'OCA\Files_Trashbin\Hooks', 'post_write_hook');
1021
+        // pre and post-rename, disable trash logic for the copy+unlink case
1022
+        \OCP\Util::connectHook('OC_Filesystem', 'delete', 'OCA\Files_Trashbin\Trashbin', 'ensureFileScannedHook');
1023
+    }
1024
+
1025
+    /**
1026
+     * check if trash bin is empty for a given user
1027
+     *
1028
+     * @param string $user
1029
+     * @return bool
1030
+     */
1031
+    public static function isEmpty($user) {
1032
+        $view = new View('/' . $user . '/files_trashbin');
1033
+        if ($view->is_dir('/files') && $dh = $view->opendir('/files')) {
1034
+            while ($file = readdir($dh)) {
1035
+                if (!Filesystem::isIgnoredDir($file)) {
1036
+                    return false;
1037
+                }
1038
+            }
1039
+        }
1040
+        return true;
1041
+    }
1042
+
1043
+    /**
1044
+     * @param $path
1045
+     * @return string
1046
+     */
1047
+    public static function preview_icon($path) {
1048
+        return \OC::$server->getURLGenerator()->linkToRoute('core_ajax_trashbin_preview', ['x' => 32, 'y' => 32, 'file' => $path]);
1049
+    }
1050 1050
 }
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 		Filesystem::initMountPoints($uid);
107 107
 		if ($uid !== User::getUser()) {
108 108
 			$info = Filesystem::getFileInfo($filename);
109
-			$ownerView = new View('/' . $uid . '/files');
109
+			$ownerView = new View('/'.$uid.'/files');
110 110
 			try {
111 111
 				$filename = $ownerView->getPath($info['fileid']);
112 112
 			} catch (NotFoundException $e) {
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	}
158 158
 
159 159
 	private static function setUpTrash($user) {
160
-		$view = new View('/' . $user);
160
+		$view = new View('/'.$user);
161 161
 		if (!$view->is_dir('files_trashbin')) {
162 162
 			$view->mkdir('files_trashbin');
163 163
 		}
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
 
193 193
 		$view = new View('/');
194 194
 
195
-		$target = $user . '/files_trashbin/files/' . $targetFilename . '.d' . $timestamp;
196
-		$source = $owner . '/files_trashbin/files/' . $sourceFilename . '.d' . $timestamp;
195
+		$target = $user.'/files_trashbin/files/'.$targetFilename.'.d'.$timestamp;
196
+		$source = $owner.'/files_trashbin/files/'.$sourceFilename.'.d'.$timestamp;
197 197
 		$free = $view->free_space($target);
198 198
 		$isUnknownOrUnlimitedFreeSpace = $free < 0;
199 199
 		$isEnoughFreeSpaceLeft = $view->filesize($source) < $free;
@@ -232,9 +232,9 @@  discard block
 block discarded – undo
232 232
 			$ownerPath = $file_path;
233 233
 		}
234 234
 
235
-		$ownerView = new View('/' . $owner);
235
+		$ownerView = new View('/'.$owner);
236 236
 		// file has been deleted in between
237
-		if (is_null($ownerPath) || $ownerPath === '' || !$ownerView->file_exists('/files/' . $ownerPath)) {
237
+		if (is_null($ownerPath) || $ownerPath === '' || !$ownerView->file_exists('/files/'.$ownerPath)) {
238 238
 			return true;
239 239
 		}
240 240
 
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 		$lockingProvider = \OC::$server->getLockingProvider();
256 256
 
257 257
 		// disable proxy to prevent recursive calls
258
-		$trashPath = '/files_trashbin/files/' . $filename . '.d' . $timestamp;
258
+		$trashPath = '/files_trashbin/files/'.$filename.'.d'.$timestamp;
259 259
 		$gotLock = false;
260 260
 
261 261
 		while (!$gotLock) {
@@ -271,12 +271,12 @@  discard block
 block discarded – undo
271 271
 
272 272
 				$timestamp = $timestamp + 1;
273 273
 
274
-				$trashPath = '/files_trashbin/files/' . $filename . '.d' . $timestamp;
274
+				$trashPath = '/files_trashbin/files/'.$filename.'.d'.$timestamp;
275 275
 			}
276 276
 		}
277 277
 
278 278
 		/** @var \OC\Files\Storage\Storage $sourceStorage */
279
-		[$sourceStorage, $sourceInternalPath] = $ownerView->resolvePath('/files/' . $ownerPath);
279
+		[$sourceStorage, $sourceInternalPath] = $ownerView->resolvePath('/files/'.$ownerPath);
280 280
 
281 281
 		try {
282 282
 			$moveSuccessful = true;
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 			if ($trashStorage->file_exists($trashInternalPath)) {
290 290
 				$trashStorage->unlink($trashInternalPath);
291 291
 			}
292
-			\OC::$server->getLogger()->error('Couldn\'t move ' . $file_path . ' to the trash bin', ['app' => 'files_trashbin']);
292
+			\OC::$server->getLogger()->error('Couldn\'t move '.$file_path.' to the trash bin', ['app' => 'files_trashbin']);
293 293
 		}
294 294
 
295 295
 		if ($sourceStorage->file_exists($sourceInternalPath)) { // failed to delete the original file, abort
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 				\OC::$server->getLogger()->error('trash bin database couldn\'t be updated', ['app' => 'files_trashbin']);
311 311
 			}
312 312
 			\OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_moveToTrash', ['filePath' => Filesystem::normalizePath($file_path),
313
-				'trashPath' => Filesystem::normalizePath($filename . '.d' . $timestamp)]);
313
+				'trashPath' => Filesystem::normalizePath($filename.'.d'.$timestamp)]);
314 314
 
315 315
 			self::retainVersions($filename, $owner, $ownerPath, $timestamp);
316 316
 
@@ -345,17 +345,17 @@  discard block
 block discarded – undo
345 345
 			$user = User::getUser();
346 346
 			$rootView = new View('/');
347 347
 
348
-			if ($rootView->is_dir($owner . '/files_versions/' . $ownerPath)) {
348
+			if ($rootView->is_dir($owner.'/files_versions/'.$ownerPath)) {
349 349
 				if ($owner !== $user) {
350
-					self::copy_recursive($owner . '/files_versions/' . $ownerPath, $owner . '/files_trashbin/versions/' . basename($ownerPath) . '.d' . $timestamp, $rootView);
350
+					self::copy_recursive($owner.'/files_versions/'.$ownerPath, $owner.'/files_trashbin/versions/'.basename($ownerPath).'.d'.$timestamp, $rootView);
351 351
 				}
352
-				self::move($rootView, $owner . '/files_versions/' . $ownerPath, $user . '/files_trashbin/versions/' . $filename . '.d' . $timestamp);
352
+				self::move($rootView, $owner.'/files_versions/'.$ownerPath, $user.'/files_trashbin/versions/'.$filename.'.d'.$timestamp);
353 353
 			} elseif ($versions = \OCA\Files_Versions\Storage::getVersions($owner, $ownerPath)) {
354 354
 				foreach ($versions as $v) {
355 355
 					if ($owner !== $user) {
356
-						self::copy($rootView, $owner . '/files_versions' . $v['path'] . '.v' . $v['version'], $owner . '/files_trashbin/versions/' . $v['name'] . '.v' . $v['version'] . '.d' . $timestamp);
356
+						self::copy($rootView, $owner.'/files_versions'.$v['path'].'.v'.$v['version'], $owner.'/files_trashbin/versions/'.$v['name'].'.v'.$v['version'].'.d'.$timestamp);
357 357
 					}
358
-					self::move($rootView, $owner . '/files_versions' . $v['path'] . '.v' . $v['version'], $user . '/files_trashbin/versions/' . $filename . '.v' . $v['version'] . '.d' . $timestamp);
358
+					self::move($rootView, $owner.'/files_versions'.$v['path'].'.v'.$v['version'], $user.'/files_trashbin/versions/'.$filename.'.v'.$v['version'].'.d'.$timestamp);
359 359
 				}
360 360
 			}
361 361
 		}
@@ -417,18 +417,18 @@  discard block
 block discarded – undo
417 417
 	 */
418 418
 	public static function restore($file, $filename, $timestamp) {
419 419
 		$user = User::getUser();
420
-		$view = new View('/' . $user);
420
+		$view = new View('/'.$user);
421 421
 
422 422
 		$location = '';
423 423
 		if ($timestamp) {
424 424
 			$location = self::getLocation($user, $filename, $timestamp);
425 425
 			if ($location === false) {
426
-				\OC::$server->getLogger()->error('trash bin database inconsistent! ($user: ' . $user . ' $filename: ' . $filename . ', $timestamp: ' . $timestamp . ')', ['app' => 'files_trashbin']);
426
+				\OC::$server->getLogger()->error('trash bin database inconsistent! ($user: '.$user.' $filename: '.$filename.', $timestamp: '.$timestamp.')', ['app' => 'files_trashbin']);
427 427
 			} else {
428 428
 				// if location no longer exists, restore file in the root directory
429 429
 				if ($location !== '/' &&
430
-					(!$view->is_dir('files/' . $location) ||
431
-						!$view->isCreatable('files/' . $location))
430
+					(!$view->is_dir('files/'.$location) ||
431
+						!$view->isCreatable('files/'.$location))
432 432
 				) {
433 433
 					$location = '';
434 434
 				}
@@ -438,8 +438,8 @@  discard block
 block discarded – undo
438 438
 		// we need a  extension in case a file/dir with the same name already exists
439 439
 		$uniqueFilename = self::getUniqueFilename($location, $filename, $view);
440 440
 
441
-		$source = Filesystem::normalizePath('files_trashbin/files/' . $file);
442
-		$target = Filesystem::normalizePath('files/' . $location . '/' . $uniqueFilename);
441
+		$source = Filesystem::normalizePath('files_trashbin/files/'.$file);
442
+		$target = Filesystem::normalizePath('files/'.$location.'/'.$uniqueFilename);
443 443
 		if (!$view->file_exists($source)) {
444 444
 			return false;
445 445
 		}
@@ -454,10 +454,10 @@  discard block
 block discarded – undo
454 454
 		// handle the restore result
455 455
 		if ($restoreResult) {
456 456
 			$fakeRoot = $view->getRoot();
457
-			$view->chroot('/' . $user . '/files');
458
-			$view->touch('/' . $location . '/' . $uniqueFilename, $mtime);
457
+			$view->chroot('/'.$user.'/files');
458
+			$view->touch('/'.$location.'/'.$uniqueFilename, $mtime);
459 459
 			$view->chroot($fakeRoot);
460
-			\OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', ['filePath' => Filesystem::normalizePath('/' . $location . '/' . $uniqueFilename),
460
+			\OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', ['filePath' => Filesystem::normalizePath('/'.$location.'/'.$uniqueFilename),
461 461
 				'trashPath' => Filesystem::normalizePath($file)]);
462 462
 
463 463
 			self::restoreVersions($view, $file, $filename, $uniqueFilename, $location, $timestamp);
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 			$user = User::getUser();
490 490
 			$rootView = new View('/');
491 491
 
492
-			$target = Filesystem::normalizePath('/' . $location . '/' . $uniqueFilename);
492
+			$target = Filesystem::normalizePath('/'.$location.'/'.$uniqueFilename);
493 493
 
494 494
 			[$owner, $ownerPath] = self::getUidAndFilename($target);
495 495
 
@@ -504,14 +504,14 @@  discard block
 block discarded – undo
504 504
 				$versionedFile = $file;
505 505
 			}
506 506
 
507
-			if ($view->is_dir('/files_trashbin/versions/' . $file)) {
508
-				$rootView->rename(Filesystem::normalizePath($user . '/files_trashbin/versions/' . $file), Filesystem::normalizePath($owner . '/files_versions/' . $ownerPath));
507
+			if ($view->is_dir('/files_trashbin/versions/'.$file)) {
508
+				$rootView->rename(Filesystem::normalizePath($user.'/files_trashbin/versions/'.$file), Filesystem::normalizePath($owner.'/files_versions/'.$ownerPath));
509 509
 			} elseif ($versions = self::getVersionsFromTrash($versionedFile, $timestamp, $user)) {
510 510
 				foreach ($versions as $v) {
511 511
 					if ($timestamp) {
512
-						$rootView->rename($user . '/files_trashbin/versions/' . $versionedFile . '.v' . $v . '.d' . $timestamp, $owner . '/files_versions/' . $ownerPath . '.v' . $v);
512
+						$rootView->rename($user.'/files_trashbin/versions/'.$versionedFile.'.v'.$v.'.d'.$timestamp, $owner.'/files_versions/'.$ownerPath.'.v'.$v);
513 513
 					} else {
514
-						$rootView->rename($user . '/files_trashbin/versions/' . $versionedFile . '.v' . $v, $owner . '/files_versions/' . $ownerPath . '.v' . $v);
514
+						$rootView->rename($user.'/files_trashbin/versions/'.$versionedFile.'.v'.$v, $owner.'/files_versions/'.$ownerPath.'.v'.$v);
515 515
 					}
516 516
 				}
517 517
 			}
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 	public static function deleteAll() {
525 525
 		$user = User::getUser();
526 526
 		$userRoot = \OC::$server->getUserFolder($user)->getParent();
527
-		$view = new View('/' . $user);
527
+		$view = new View('/'.$user);
528 528
 		$fileInfos = $view->getDirectoryContent('files_trashbin/files');
529 529
 
530 530
 		try {
@@ -596,13 +596,13 @@  discard block
 block discarded – undo
596 596
 	 */
597 597
 	public static function delete($filename, $user, $timestamp = null) {
598 598
 		$userRoot = \OC::$server->getUserFolder($user)->getParent();
599
-		$view = new View('/' . $user);
599
+		$view = new View('/'.$user);
600 600
 		$size = 0;
601 601
 
602 602
 		if ($timestamp) {
603 603
 			$query = \OC_DB::prepare('DELETE FROM `*PREFIX*files_trash` WHERE `user`=? AND `id`=? AND `timestamp`=?');
604 604
 			$query->execute([$user, $filename, $timestamp]);
605
-			$file = $filename . '.d' . $timestamp;
605
+			$file = $filename.'.d'.$timestamp;
606 606
 		} else {
607 607
 			$file = $filename;
608 608
 		}
@@ -610,20 +610,20 @@  discard block
 block discarded – undo
610 610
 		$size += self::deleteVersions($view, $file, $filename, $timestamp, $user);
611 611
 
612 612
 		try {
613
-			$node = $userRoot->get('/files_trashbin/files/' . $file);
613
+			$node = $userRoot->get('/files_trashbin/files/'.$file);
614 614
 		} catch (NotFoundException $e) {
615 615
 			return $size;
616 616
 		}
617 617
 
618 618
 		if ($node instanceof Folder) {
619
-			$size += self::calculateSize(new View('/' . $user . '/files_trashbin/files/' . $file));
619
+			$size += self::calculateSize(new View('/'.$user.'/files_trashbin/files/'.$file));
620 620
 		} elseif ($node instanceof File) {
621
-			$size += $view->filesize('/files_trashbin/files/' . $file);
621
+			$size += $view->filesize('/files_trashbin/files/'.$file);
622 622
 		}
623 623
 
624
-		self::emitTrashbinPreDelete('/files_trashbin/files/' . $file);
624
+		self::emitTrashbinPreDelete('/files_trashbin/files/'.$file);
625 625
 		$node->delete();
626
-		self::emitTrashbinPostDelete('/files_trashbin/files/' . $file);
626
+		self::emitTrashbinPostDelete('/files_trashbin/files/'.$file);
627 627
 
628 628
 		return $size;
629 629
 	}
@@ -639,17 +639,17 @@  discard block
 block discarded – undo
639 639
 	private static function deleteVersions(View $view, $file, $filename, $timestamp, $user) {
640 640
 		$size = 0;
641 641
 		if (\OCP\App::isEnabled('files_versions')) {
642
-			if ($view->is_dir('files_trashbin/versions/' . $file)) {
643
-				$size += self::calculateSize(new View('/' . $user . '/files_trashbin/versions/' . $file));
644
-				$view->unlink('files_trashbin/versions/' . $file);
642
+			if ($view->is_dir('files_trashbin/versions/'.$file)) {
643
+				$size += self::calculateSize(new View('/'.$user.'/files_trashbin/versions/'.$file));
644
+				$view->unlink('files_trashbin/versions/'.$file);
645 645
 			} elseif ($versions = self::getVersionsFromTrash($filename, $timestamp, $user)) {
646 646
 				foreach ($versions as $v) {
647 647
 					if ($timestamp) {
648
-						$size += $view->filesize('/files_trashbin/versions/' . $filename . '.v' . $v . '.d' . $timestamp);
649
-						$view->unlink('/files_trashbin/versions/' . $filename . '.v' . $v . '.d' . $timestamp);
648
+						$size += $view->filesize('/files_trashbin/versions/'.$filename.'.v'.$v.'.d'.$timestamp);
649
+						$view->unlink('/files_trashbin/versions/'.$filename.'.v'.$v.'.d'.$timestamp);
650 650
 					} else {
651
-						$size += $view->filesize('/files_trashbin/versions/' . $filename . '.v' . $v);
652
-						$view->unlink('/files_trashbin/versions/' . $filename . '.v' . $v);
651
+						$size += $view->filesize('/files_trashbin/versions/'.$filename.'.v'.$v);
652
+						$view->unlink('/files_trashbin/versions/'.$filename.'.v'.$v);
653 653
 					}
654 654
 				}
655 655
 			}
@@ -666,13 +666,13 @@  discard block
 block discarded – undo
666 666
 	 */
667 667
 	public static function file_exists($filename, $timestamp = null) {
668 668
 		$user = User::getUser();
669
-		$view = new View('/' . $user);
669
+		$view = new View('/'.$user);
670 670
 
671 671
 		if ($timestamp) {
672
-			$filename = $filename . '.d' . $timestamp;
672
+			$filename = $filename.'.d'.$timestamp;
673 673
 		}
674 674
 
675
-		$target = Filesystem::normalizePath('files_trashbin/files/' . $filename);
675
+		$target = Filesystem::normalizePath('files_trashbin/files/'.$filename);
676 676
 		return $view->file_exists($target);
677 677
 	}
678 678
 
@@ -696,8 +696,8 @@  discard block
 block discarded – undo
696 696
 	 */
697 697
 	private static function calculateFreeSpace($trashbinSize, $user) {
698 698
 		$config = \OC::$server->getConfig();
699
-		$systemTrashbinSize = (int)$config->getAppValue('files_trashbin', 'trashbin_size', '-1');
700
-		$userTrashbinSize = (int)$config->getUserValue($user, 'files_trashbin', 'trashbin_size', '-1');
699
+		$systemTrashbinSize = (int) $config->getAppValue('files_trashbin', 'trashbin_size', '-1');
700
+		$userTrashbinSize = (int) $config->getUserValue($user, 'files_trashbin', 'trashbin_size', '-1');
701 701
 		$configuredTrashbinSize = ($userTrashbinSize < 0) ? $systemTrashbinSize : $userTrashbinSize;
702 702
 		if ($configuredTrashbinSize) {
703 703
 			return $configuredTrashbinSize - $trashbinSize;
@@ -807,7 +807,7 @@  discard block
 block discarded – undo
807 807
 			foreach ($files as $file) {
808 808
 				if ($availableSpace < 0 && $expiration->isExpired($file['mtime'], true)) {
809 809
 					$tmp = self::delete($file['name'], $user, $file['mtime']);
810
-					\OC::$server->getLogger()->info('remove "' . $file['name'] . '" (' . $tmp . 'B) to meet the limit of trash bin size (50% of available quota)', ['app' => 'files_trashbin']);
810
+					\OC::$server->getLogger()->info('remove "'.$file['name'].'" ('.$tmp.'B) to meet the limit of trash bin size (50% of available quota)', ['app' => 'files_trashbin']);
811 811
 					$availableSpace += $tmp;
812 812
 					$size += $tmp;
813 813
 				} else {
@@ -838,10 +838,10 @@  discard block
 block discarded – undo
838 838
 					$size += self::delete($filename, $user, $timestamp);
839 839
 					$count++;
840 840
 				} catch (\OCP\Files\NotPermittedException $e) {
841
-					\OC::$server->getLogger()->logException($e, ['app' => 'files_trashbin', 'level' => \OCP\ILogger::WARN, 'message' => 'Removing "' . $filename . '" from trashbin failed.']);
841
+					\OC::$server->getLogger()->logException($e, ['app' => 'files_trashbin', 'level' => \OCP\ILogger::WARN, 'message' => 'Removing "'.$filename.'" from trashbin failed.']);
842 842
 				}
843 843
 				\OC::$server->getLogger()->info(
844
-					'Remove "' . $filename . '" from trashbin because it exceeds max retention obligation term.',
844
+					'Remove "'.$filename.'" from trashbin because it exceeds max retention obligation term.',
845 845
 					['app' => 'files_trashbin']
846 846
 				);
847 847
 			} else {
@@ -867,16 +867,16 @@  discard block
 block discarded – undo
867 867
 			$view->mkdir($destination);
868 868
 			$view->touch($destination, $view->filemtime($source));
869 869
 			foreach ($view->getDirectoryContent($source) as $i) {
870
-				$pathDir = $source . '/' . $i['name'];
870
+				$pathDir = $source.'/'.$i['name'];
871 871
 				if ($view->is_dir($pathDir)) {
872
-					$size += self::copy_recursive($pathDir, $destination . '/' . $i['name'], $view);
872
+					$size += self::copy_recursive($pathDir, $destination.'/'.$i['name'], $view);
873 873
 				} else {
874 874
 					$size += $view->filesize($pathDir);
875
-					$result = $view->copy($pathDir, $destination . '/' . $i['name']);
875
+					$result = $view->copy($pathDir, $destination.'/'.$i['name']);
876 876
 					if (!$result) {
877 877
 						throw new \OCA\Files_Trashbin\Exceptions\CopyRecursiveException();
878 878
 					}
879
-					$view->touch($destination . '/' . $i['name'], $view->filemtime($pathDir));
879
+					$view->touch($destination.'/'.$i['name'], $view->filemtime($pathDir));
880 880
 				}
881 881
 			}
882 882
 		} else {
@@ -898,23 +898,23 @@  discard block
 block discarded – undo
898 898
 	 * @return array
899 899
 	 */
900 900
 	private static function getVersionsFromTrash($filename, $timestamp, $user) {
901
-		$view = new View('/' . $user . '/files_trashbin/versions');
901
+		$view = new View('/'.$user.'/files_trashbin/versions');
902 902
 		$versions = [];
903 903
 
904 904
 		//force rescan of versions, local storage may not have updated the cache
905 905
 		if (!self::$scannedVersions) {
906 906
 			/** @var \OC\Files\Storage\Storage $storage */
907
-			[$storage,] = $view->resolvePath('/');
907
+			[$storage, ] = $view->resolvePath('/');
908 908
 			$storage->getScanner()->scan('files_trashbin/versions');
909 909
 			self::$scannedVersions = true;
910 910
 		}
911 911
 
912 912
 		if ($timestamp) {
913 913
 			// fetch for old versions
914
-			$matches = $view->searchRaw($filename . '.v%.d' . $timestamp);
914
+			$matches = $view->searchRaw($filename.'.v%.d'.$timestamp);
915 915
 			$offset = -strlen($timestamp) - 2;
916 916
 		} else {
917
-			$matches = $view->searchRaw($filename . '.v%');
917
+			$matches = $view->searchRaw($filename.'.v%');
918 918
 		}
919 919
 
920 920
 		if (is_array($matches)) {
@@ -944,18 +944,18 @@  discard block
 block discarded – undo
944 944
 		$name = pathinfo($filename, PATHINFO_FILENAME);
945 945
 		$l = \OC::$server->getL10N('files_trashbin');
946 946
 
947
-		$location = '/' . trim($location, '/');
947
+		$location = '/'.trim($location, '/');
948 948
 
949 949
 		// if extension is not empty we set a dot in front of it
950 950
 		if ($ext !== '') {
951
-			$ext = '.' . $ext;
951
+			$ext = '.'.$ext;
952 952
 		}
953 953
 
954
-		if ($view->file_exists('files' . $location . '/' . $filename)) {
954
+		if ($view->file_exists('files'.$location.'/'.$filename)) {
955 955
 			$i = 2;
956
-			$uniqueName = $name . " (" . $l->t("restored") . ")" . $ext;
957
-			while ($view->file_exists('files' . $location . '/' . $uniqueName)) {
958
-				$uniqueName = $name . " (" . $l->t("restored") . " " . $i . ")" . $ext;
956
+			$uniqueName = $name." (".$l->t("restored").")".$ext;
957
+			while ($view->file_exists('files'.$location.'/'.$uniqueName)) {
958
+				$uniqueName = $name." (".$l->t("restored")." ".$i.")".$ext;
959 959
 				$i++;
960 960
 			}
961 961
 
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
 	 * @return integer size of the folder
973 973
 	 */
974 974
 	private static function calculateSize($view) {
975
-		$root = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . $view->getAbsolutePath('');
975
+		$root = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data').$view->getAbsolutePath('');
976 976
 		if (!file_exists($root)) {
977 977
 			return 0;
978 978
 		}
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
 	 * @return integer trash bin size
1004 1004
 	 */
1005 1005
 	private static function getTrashbinSize($user) {
1006
-		$view = new View('/' . $user);
1006
+		$view = new View('/'.$user);
1007 1007
 		$fileInfo = $view->getFileInfo('/files_trashbin');
1008 1008
 		return isset($fileInfo['size']) ? $fileInfo['size'] : 0;
1009 1009
 	}
@@ -1029,7 +1029,7 @@  discard block
 block discarded – undo
1029 1029
 	 * @return bool
1030 1030
 	 */
1031 1031
 	public static function isEmpty($user) {
1032
-		$view = new View('/' . $user . '/files_trashbin');
1032
+		$view = new View('/'.$user.'/files_trashbin');
1033 1033
 		if ($view->is_dir('/files') && $dh = $view->opendir('/files')) {
1034 1034
 			while ($file = readdir($dh)) {
1035 1035
 				if (!Filesystem::isIgnoredDir($file)) {
Please login to merge, or discard this patch.
apps/files_trashbin/lib/Command/Size.php 2 patches
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -34,113 +34,113 @@
 block discarded – undo
34 34
 use Symfony\Component\Console\Output\OutputInterface;
35 35
 
36 36
 class Size extends Base {
37
-	private $config;
38
-	private $userManager;
39
-	private $commandBus;
37
+    private $config;
38
+    private $userManager;
39
+    private $commandBus;
40 40
 
41
-	public function __construct(
42
-		IConfig $config,
43
-		IUserManager $userManager,
44
-		IBus $commandBus
45
-	) {
46
-		parent::__construct();
41
+    public function __construct(
42
+        IConfig $config,
43
+        IUserManager $userManager,
44
+        IBus $commandBus
45
+    ) {
46
+        parent::__construct();
47 47
 
48
-		$this->config = $config;
49
-		$this->userManager = $userManager;
50
-		$this->commandBus = $commandBus;
51
-	}
48
+        $this->config = $config;
49
+        $this->userManager = $userManager;
50
+        $this->commandBus = $commandBus;
51
+    }
52 52
 
53
-	protected function configure() {
54
-		parent::configure();
55
-		$this
56
-			->setName('trashbin:size')
57
-			->setDescription('Configure the target trashbin size')
58
-			->addOption('user', 'u', InputOption::VALUE_REQUIRED, 'configure the target size for the provided user, if no user is given the default size is configured')
59
-			->addArgument(
60
-				'size',
61
-				InputArgument::OPTIONAL,
62
-				'the target size for the trashbin, if not provided the current trashbin size will be returned'
63
-			);
64
-	}
53
+    protected function configure() {
54
+        parent::configure();
55
+        $this
56
+            ->setName('trashbin:size')
57
+            ->setDescription('Configure the target trashbin size')
58
+            ->addOption('user', 'u', InputOption::VALUE_REQUIRED, 'configure the target size for the provided user, if no user is given the default size is configured')
59
+            ->addArgument(
60
+                'size',
61
+                InputArgument::OPTIONAL,
62
+                'the target size for the trashbin, if not provided the current trashbin size will be returned'
63
+            );
64
+    }
65 65
 
66
-	protected function execute(InputInterface $input, OutputInterface $output): int {
67
-		$user = $input->getOption('user');
68
-		$size = $input->getArgument('size');
66
+    protected function execute(InputInterface $input, OutputInterface $output): int {
67
+        $user = $input->getOption('user');
68
+        $size = $input->getArgument('size');
69 69
 
70
-		if ($size) {
71
-			$parsedSize = \OC_Helper::computerFileSize($size);
72
-			if ($parsedSize === false) {
73
-				$output->writeln("<error>Failed to parse input size</error>");
74
-				return -1;
75
-			}
76
-			if ($user) {
77
-				$this->config->setUserValue($user, 'files_trashbin', 'trashbin_size', (string)$parsedSize);
78
-				$this->commandBus->push(new Expire($user));
79
-			} else {
80
-				$this->config->setAppValue('files_trashbin', 'trashbin_size', (string)$parsedSize);
81
-				$output->writeln("<info>Warning: changing the default trashbin size will automatically trigger cleanup of existing trashbins,</info>");
82
-				$output->writeln("<info>a users trashbin can exceed the configured size until they move a new file to the trashbin.</info>");
83
-			}
84
-		} else {
85
-			$this->printTrashbinSize($input, $output, $user);
86
-		}
70
+        if ($size) {
71
+            $parsedSize = \OC_Helper::computerFileSize($size);
72
+            if ($parsedSize === false) {
73
+                $output->writeln("<error>Failed to parse input size</error>");
74
+                return -1;
75
+            }
76
+            if ($user) {
77
+                $this->config->setUserValue($user, 'files_trashbin', 'trashbin_size', (string)$parsedSize);
78
+                $this->commandBus->push(new Expire($user));
79
+            } else {
80
+                $this->config->setAppValue('files_trashbin', 'trashbin_size', (string)$parsedSize);
81
+                $output->writeln("<info>Warning: changing the default trashbin size will automatically trigger cleanup of existing trashbins,</info>");
82
+                $output->writeln("<info>a users trashbin can exceed the configured size until they move a new file to the trashbin.</info>");
83
+            }
84
+        } else {
85
+            $this->printTrashbinSize($input, $output, $user);
86
+        }
87 87
 
88
-		return 0;
89
-	}
88
+        return 0;
89
+    }
90 90
 
91
-	private function printTrashbinSize(InputInterface $input, OutputInterface $output, ?string $user) {
92
-		$globalSize = (int)$this->config->getAppValue('files_trashbin', 'trashbin_size', '-1');
93
-		if ($globalSize < 0) {
94
-			$globalHumanSize = "default (50% of available space)";
95
-		} else {
96
-			$globalHumanSize = \OC_Helper::humanFileSize($globalSize);
97
-		}
91
+    private function printTrashbinSize(InputInterface $input, OutputInterface $output, ?string $user) {
92
+        $globalSize = (int)$this->config->getAppValue('files_trashbin', 'trashbin_size', '-1');
93
+        if ($globalSize < 0) {
94
+            $globalHumanSize = "default (50% of available space)";
95
+        } else {
96
+            $globalHumanSize = \OC_Helper::humanFileSize($globalSize);
97
+        }
98 98
 
99
-		if ($user) {
100
-			$userSize = (int)$this->config->getUserValue($user, 'files_trashbin', 'trashbin_size', '-1');
99
+        if ($user) {
100
+            $userSize = (int)$this->config->getUserValue($user, 'files_trashbin', 'trashbin_size', '-1');
101 101
 
102
-			if ($userSize < 0) {
103
-				$userHumanSize = ($globalSize < 0) ? $globalHumanSize : "default($globalHumanSize)";
104
-			} else {
105
-				$userHumanSize = \OC_Helper::humanFileSize($userSize);
106
-			}
102
+            if ($userSize < 0) {
103
+                $userHumanSize = ($globalSize < 0) ? $globalHumanSize : "default($globalHumanSize)";
104
+            } else {
105
+                $userHumanSize = \OC_Helper::humanFileSize($userSize);
106
+            }
107 107
 
108
-			if ($input->getOption('output') == self::OUTPUT_FORMAT_PLAIN) {
109
-				$output->writeln($userHumanSize);
110
-			} else {
111
-				$userValue = ($userSize < 0) ? 'default' : $userSize;
112
-				$globalValue = ($globalSize < 0) ? 'default' : $globalSize;
113
-				$this->writeArrayInOutputFormat($input, $output, [
114
-					'user_size' => $userValue,
115
-					'global_size' => $globalValue,
116
-					'effective_size' => ($userSize < 0) ? $globalValue : $userValue,
117
-				]);
118
-			}
119
-		} else {
120
-			$users = [];
121
-			$this->userManager->callForSeenUsers(function (IUser $user) use (&$users) {
122
-				$users[] = $user->getUID();
123
-			});
124
-			$userValues = $this->config->getUserValueForUsers('files_trashbin', 'trashbin_size', $users);
108
+            if ($input->getOption('output') == self::OUTPUT_FORMAT_PLAIN) {
109
+                $output->writeln($userHumanSize);
110
+            } else {
111
+                $userValue = ($userSize < 0) ? 'default' : $userSize;
112
+                $globalValue = ($globalSize < 0) ? 'default' : $globalSize;
113
+                $this->writeArrayInOutputFormat($input, $output, [
114
+                    'user_size' => $userValue,
115
+                    'global_size' => $globalValue,
116
+                    'effective_size' => ($userSize < 0) ? $globalValue : $userValue,
117
+                ]);
118
+            }
119
+        } else {
120
+            $users = [];
121
+            $this->userManager->callForSeenUsers(function (IUser $user) use (&$users) {
122
+                $users[] = $user->getUID();
123
+            });
124
+            $userValues = $this->config->getUserValueForUsers('files_trashbin', 'trashbin_size', $users);
125 125
 
126
-			if ($input->getOption('output') == self::OUTPUT_FORMAT_PLAIN) {
127
-				$output->writeln("Default size: $globalHumanSize");
128
-				$output->writeln("");
129
-				if (count($userValues)) {
130
-					$output->writeln("Per-user sizes:");
131
-					$this->writeArrayInOutputFormat($input, $output, array_map(function ($size) {
132
-						return \OC_Helper::humanFileSize($size);
133
-					}, $userValues));
134
-				} else {
135
-					$output->writeln("No per-user sizes configured");
136
-				}
137
-			} else {
138
-				$globalValue = ($globalSize < 0) ? 'default' : $globalSize;
139
-				$this->writeArrayInOutputFormat($input, $output, [
140
-					'global_size' => $globalValue,
141
-					'user_sizes' => $userValues,
142
-				]);
143
-			}
144
-		}
145
-	}
126
+            if ($input->getOption('output') == self::OUTPUT_FORMAT_PLAIN) {
127
+                $output->writeln("Default size: $globalHumanSize");
128
+                $output->writeln("");
129
+                if (count($userValues)) {
130
+                    $output->writeln("Per-user sizes:");
131
+                    $this->writeArrayInOutputFormat($input, $output, array_map(function ($size) {
132
+                        return \OC_Helper::humanFileSize($size);
133
+                    }, $userValues));
134
+                } else {
135
+                    $output->writeln("No per-user sizes configured");
136
+                }
137
+            } else {
138
+                $globalValue = ($globalSize < 0) ? 'default' : $globalSize;
139
+                $this->writeArrayInOutputFormat($input, $output, [
140
+                    'global_size' => $globalValue,
141
+                    'user_sizes' => $userValues,
142
+                ]);
143
+            }
144
+        }
145
+    }
146 146
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
 				return -1;
75 75
 			}
76 76
 			if ($user) {
77
-				$this->config->setUserValue($user, 'files_trashbin', 'trashbin_size', (string)$parsedSize);
77
+				$this->config->setUserValue($user, 'files_trashbin', 'trashbin_size', (string) $parsedSize);
78 78
 				$this->commandBus->push(new Expire($user));
79 79
 			} else {
80
-				$this->config->setAppValue('files_trashbin', 'trashbin_size', (string)$parsedSize);
80
+				$this->config->setAppValue('files_trashbin', 'trashbin_size', (string) $parsedSize);
81 81
 				$output->writeln("<info>Warning: changing the default trashbin size will automatically trigger cleanup of existing trashbins,</info>");
82 82
 				$output->writeln("<info>a users trashbin can exceed the configured size until they move a new file to the trashbin.</info>");
83 83
 			}
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	}
90 90
 
91 91
 	private function printTrashbinSize(InputInterface $input, OutputInterface $output, ?string $user) {
92
-		$globalSize = (int)$this->config->getAppValue('files_trashbin', 'trashbin_size', '-1');
92
+		$globalSize = (int) $this->config->getAppValue('files_trashbin', 'trashbin_size', '-1');
93 93
 		if ($globalSize < 0) {
94 94
 			$globalHumanSize = "default (50% of available space)";
95 95
 		} else {
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 		}
98 98
 
99 99
 		if ($user) {
100
-			$userSize = (int)$this->config->getUserValue($user, 'files_trashbin', 'trashbin_size', '-1');
100
+			$userSize = (int) $this->config->getUserValue($user, 'files_trashbin', 'trashbin_size', '-1');
101 101
 
102 102
 			if ($userSize < 0) {
103 103
 				$userHumanSize = ($globalSize < 0) ? $globalHumanSize : "default($globalHumanSize)";
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 			}
119 119
 		} else {
120 120
 			$users = [];
121
-			$this->userManager->callForSeenUsers(function (IUser $user) use (&$users) {
121
+			$this->userManager->callForSeenUsers(function(IUser $user) use (&$users) {
122 122
 				$users[] = $user->getUID();
123 123
 			});
124 124
 			$userValues = $this->config->getUserValueForUsers('files_trashbin', 'trashbin_size', $users);
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 				$output->writeln("");
129 129
 				if (count($userValues)) {
130 130
 					$output->writeln("Per-user sizes:");
131
-					$this->writeArrayInOutputFormat($input, $output, array_map(function ($size) {
131
+					$this->writeArrayInOutputFormat($input, $output, array_map(function($size) {
132 132
 						return \OC_Helper::humanFileSize($size);
133 133
 					}, $userValues));
134 134
 				} else {
Please login to merge, or discard this patch.
apps/files_trashbin/composer/composer/autoload_static.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -6,62 +6,62 @@
 block discarded – undo
6 6
 
7 7
 class ComposerStaticInitFiles_Trashbin
8 8
 {
9
-    public static $prefixLengthsPsr4 = array (
9
+    public static $prefixLengthsPsr4 = array(
10 10
         'O' => 
11
-        array (
11
+        array(
12 12
             'OCA\\Files_Trashbin\\' => 19,
13 13
         ),
14 14
     );
15 15
 
16
-    public static $prefixDirsPsr4 = array (
16
+    public static $prefixDirsPsr4 = array(
17 17
         'OCA\\Files_Trashbin\\' => 
18
-        array (
19
-            0 => __DIR__ . '/..' . '/../lib',
18
+        array(
19
+            0 => __DIR__.'/..'.'/../lib',
20 20
         ),
21 21
     );
22 22
 
23
-    public static $classMap = array (
24
-        'OCA\\Files_Trashbin\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php',
25
-        'OCA\\Files_Trashbin\\BackgroundJob\\ExpireTrash' => __DIR__ . '/..' . '/../lib/BackgroundJob/ExpireTrash.php',
26
-        'OCA\\Files_Trashbin\\Capabilities' => __DIR__ . '/..' . '/../lib/Capabilities.php',
27
-        'OCA\\Files_Trashbin\\Command\\CleanUp' => __DIR__ . '/..' . '/../lib/Command/CleanUp.php',
28
-        'OCA\\Files_Trashbin\\Command\\Expire' => __DIR__ . '/..' . '/../lib/Command/Expire.php',
29
-        'OCA\\Files_Trashbin\\Command\\ExpireTrash' => __DIR__ . '/..' . '/../lib/Command/ExpireTrash.php',
30
-        'OCA\\Files_Trashbin\\Command\\Size' => __DIR__ . '/..' . '/../lib/Command/Size.php',
31
-        'OCA\\Files_Trashbin\\Controller\\PreviewController' => __DIR__ . '/..' . '/../lib/Controller/PreviewController.php',
32
-        'OCA\\Files_Trashbin\\Events\\MoveToTrashEvent' => __DIR__ . '/..' . '/../lib/Events/MoveToTrashEvent.php',
33
-        'OCA\\Files_Trashbin\\Exceptions\\CopyRecursiveException' => __DIR__ . '/..' . '/../lib/Exceptions/CopyRecursiveException.php',
34
-        'OCA\\Files_Trashbin\\Expiration' => __DIR__ . '/..' . '/../lib/Expiration.php',
35
-        'OCA\\Files_Trashbin\\Helper' => __DIR__ . '/..' . '/../lib/Helper.php',
36
-        'OCA\\Files_Trashbin\\Hooks' => __DIR__ . '/..' . '/../lib/Hooks.php',
37
-        'OCA\\Files_Trashbin\\Migration\\Version1010Date20200630192639' => __DIR__ . '/..' . '/../lib/Migration/Version1010Date20200630192639.php',
38
-        'OCA\\Files_Trashbin\\Sabre\\AbstractTrash' => __DIR__ . '/..' . '/../lib/Sabre/AbstractTrash.php',
39
-        'OCA\\Files_Trashbin\\Sabre\\AbstractTrashFile' => __DIR__ . '/..' . '/../lib/Sabre/AbstractTrashFile.php',
40
-        'OCA\\Files_Trashbin\\Sabre\\AbstractTrashFolder' => __DIR__ . '/..' . '/../lib/Sabre/AbstractTrashFolder.php',
41
-        'OCA\\Files_Trashbin\\Sabre\\ITrash' => __DIR__ . '/..' . '/../lib/Sabre/ITrash.php',
42
-        'OCA\\Files_Trashbin\\Sabre\\PropfindPlugin' => __DIR__ . '/..' . '/../lib/Sabre/PropfindPlugin.php',
43
-        'OCA\\Files_Trashbin\\Sabre\\RestoreFolder' => __DIR__ . '/..' . '/../lib/Sabre/RestoreFolder.php',
44
-        'OCA\\Files_Trashbin\\Sabre\\RootCollection' => __DIR__ . '/..' . '/../lib/Sabre/RootCollection.php',
45
-        'OCA\\Files_Trashbin\\Sabre\\TrashFile' => __DIR__ . '/..' . '/../lib/Sabre/TrashFile.php',
46
-        'OCA\\Files_Trashbin\\Sabre\\TrashFolder' => __DIR__ . '/..' . '/../lib/Sabre/TrashFolder.php',
47
-        'OCA\\Files_Trashbin\\Sabre\\TrashFolderFile' => __DIR__ . '/..' . '/../lib/Sabre/TrashFolderFile.php',
48
-        'OCA\\Files_Trashbin\\Sabre\\TrashFolderFolder' => __DIR__ . '/..' . '/../lib/Sabre/TrashFolderFolder.php',
49
-        'OCA\\Files_Trashbin\\Sabre\\TrashHome' => __DIR__ . '/..' . '/../lib/Sabre/TrashHome.php',
50
-        'OCA\\Files_Trashbin\\Sabre\\TrashRoot' => __DIR__ . '/..' . '/../lib/Sabre/TrashRoot.php',
51
-        'OCA\\Files_Trashbin\\Storage' => __DIR__ . '/..' . '/../lib/Storage.php',
52
-        'OCA\\Files_Trashbin\\Trash\\BackendNotFoundException' => __DIR__ . '/..' . '/../lib/Trash/BackendNotFoundException.php',
53
-        'OCA\\Files_Trashbin\\Trash\\ITrashBackend' => __DIR__ . '/..' . '/../lib/Trash/ITrashBackend.php',
54
-        'OCA\\Files_Trashbin\\Trash\\ITrashItem' => __DIR__ . '/..' . '/../lib/Trash/ITrashItem.php',
55
-        'OCA\\Files_Trashbin\\Trash\\ITrashManager' => __DIR__ . '/..' . '/../lib/Trash/ITrashManager.php',
56
-        'OCA\\Files_Trashbin\\Trash\\LegacyTrashBackend' => __DIR__ . '/..' . '/../lib/Trash/LegacyTrashBackend.php',
57
-        'OCA\\Files_Trashbin\\Trash\\TrashItem' => __DIR__ . '/..' . '/../lib/Trash/TrashItem.php',
58
-        'OCA\\Files_Trashbin\\Trash\\TrashManager' => __DIR__ . '/..' . '/../lib/Trash/TrashManager.php',
59
-        'OCA\\Files_Trashbin\\Trashbin' => __DIR__ . '/..' . '/../lib/Trashbin.php',
23
+    public static $classMap = array(
24
+        'OCA\\Files_Trashbin\\AppInfo\\Application' => __DIR__.'/..'.'/../lib/AppInfo/Application.php',
25
+        'OCA\\Files_Trashbin\\BackgroundJob\\ExpireTrash' => __DIR__.'/..'.'/../lib/BackgroundJob/ExpireTrash.php',
26
+        'OCA\\Files_Trashbin\\Capabilities' => __DIR__.'/..'.'/../lib/Capabilities.php',
27
+        'OCA\\Files_Trashbin\\Command\\CleanUp' => __DIR__.'/..'.'/../lib/Command/CleanUp.php',
28
+        'OCA\\Files_Trashbin\\Command\\Expire' => __DIR__.'/..'.'/../lib/Command/Expire.php',
29
+        'OCA\\Files_Trashbin\\Command\\ExpireTrash' => __DIR__.'/..'.'/../lib/Command/ExpireTrash.php',
30
+        'OCA\\Files_Trashbin\\Command\\Size' => __DIR__.'/..'.'/../lib/Command/Size.php',
31
+        'OCA\\Files_Trashbin\\Controller\\PreviewController' => __DIR__.'/..'.'/../lib/Controller/PreviewController.php',
32
+        'OCA\\Files_Trashbin\\Events\\MoveToTrashEvent' => __DIR__.'/..'.'/../lib/Events/MoveToTrashEvent.php',
33
+        'OCA\\Files_Trashbin\\Exceptions\\CopyRecursiveException' => __DIR__.'/..'.'/../lib/Exceptions/CopyRecursiveException.php',
34
+        'OCA\\Files_Trashbin\\Expiration' => __DIR__.'/..'.'/../lib/Expiration.php',
35
+        'OCA\\Files_Trashbin\\Helper' => __DIR__.'/..'.'/../lib/Helper.php',
36
+        'OCA\\Files_Trashbin\\Hooks' => __DIR__.'/..'.'/../lib/Hooks.php',
37
+        'OCA\\Files_Trashbin\\Migration\\Version1010Date20200630192639' => __DIR__.'/..'.'/../lib/Migration/Version1010Date20200630192639.php',
38
+        'OCA\\Files_Trashbin\\Sabre\\AbstractTrash' => __DIR__.'/..'.'/../lib/Sabre/AbstractTrash.php',
39
+        'OCA\\Files_Trashbin\\Sabre\\AbstractTrashFile' => __DIR__.'/..'.'/../lib/Sabre/AbstractTrashFile.php',
40
+        'OCA\\Files_Trashbin\\Sabre\\AbstractTrashFolder' => __DIR__.'/..'.'/../lib/Sabre/AbstractTrashFolder.php',
41
+        'OCA\\Files_Trashbin\\Sabre\\ITrash' => __DIR__.'/..'.'/../lib/Sabre/ITrash.php',
42
+        'OCA\\Files_Trashbin\\Sabre\\PropfindPlugin' => __DIR__.'/..'.'/../lib/Sabre/PropfindPlugin.php',
43
+        'OCA\\Files_Trashbin\\Sabre\\RestoreFolder' => __DIR__.'/..'.'/../lib/Sabre/RestoreFolder.php',
44
+        'OCA\\Files_Trashbin\\Sabre\\RootCollection' => __DIR__.'/..'.'/../lib/Sabre/RootCollection.php',
45
+        'OCA\\Files_Trashbin\\Sabre\\TrashFile' => __DIR__.'/..'.'/../lib/Sabre/TrashFile.php',
46
+        'OCA\\Files_Trashbin\\Sabre\\TrashFolder' => __DIR__.'/..'.'/../lib/Sabre/TrashFolder.php',
47
+        'OCA\\Files_Trashbin\\Sabre\\TrashFolderFile' => __DIR__.'/..'.'/../lib/Sabre/TrashFolderFile.php',
48
+        'OCA\\Files_Trashbin\\Sabre\\TrashFolderFolder' => __DIR__.'/..'.'/../lib/Sabre/TrashFolderFolder.php',
49
+        'OCA\\Files_Trashbin\\Sabre\\TrashHome' => __DIR__.'/..'.'/../lib/Sabre/TrashHome.php',
50
+        'OCA\\Files_Trashbin\\Sabre\\TrashRoot' => __DIR__.'/..'.'/../lib/Sabre/TrashRoot.php',
51
+        'OCA\\Files_Trashbin\\Storage' => __DIR__.'/..'.'/../lib/Storage.php',
52
+        'OCA\\Files_Trashbin\\Trash\\BackendNotFoundException' => __DIR__.'/..'.'/../lib/Trash/BackendNotFoundException.php',
53
+        'OCA\\Files_Trashbin\\Trash\\ITrashBackend' => __DIR__.'/..'.'/../lib/Trash/ITrashBackend.php',
54
+        'OCA\\Files_Trashbin\\Trash\\ITrashItem' => __DIR__.'/..'.'/../lib/Trash/ITrashItem.php',
55
+        'OCA\\Files_Trashbin\\Trash\\ITrashManager' => __DIR__.'/..'.'/../lib/Trash/ITrashManager.php',
56
+        'OCA\\Files_Trashbin\\Trash\\LegacyTrashBackend' => __DIR__.'/..'.'/../lib/Trash/LegacyTrashBackend.php',
57
+        'OCA\\Files_Trashbin\\Trash\\TrashItem' => __DIR__.'/..'.'/../lib/Trash/TrashItem.php',
58
+        'OCA\\Files_Trashbin\\Trash\\TrashManager' => __DIR__.'/..'.'/../lib/Trash/TrashManager.php',
59
+        'OCA\\Files_Trashbin\\Trashbin' => __DIR__.'/..'.'/../lib/Trashbin.php',
60 60
     );
61 61
 
62 62
     public static function getInitializer(ClassLoader $loader)
63 63
     {
64
-        return \Closure::bind(function () use ($loader) {
64
+        return \Closure::bind(function() use ($loader) {
65 65
             $loader->prefixLengthsPsr4 = ComposerStaticInitFiles_Trashbin::$prefixLengthsPsr4;
66 66
             $loader->prefixDirsPsr4 = ComposerStaticInitFiles_Trashbin::$prefixDirsPsr4;
67 67
             $loader->classMap = ComposerStaticInitFiles_Trashbin::$classMap;
Please login to merge, or discard this patch.
apps/files_trashbin/composer/composer/autoload_classmap.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -6,40 +6,40 @@
 block discarded – undo
6 6
 $baseDir = $vendorDir;
7 7
 
8 8
 return array(
9
-    'OCA\\Files_Trashbin\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php',
10
-    'OCA\\Files_Trashbin\\BackgroundJob\\ExpireTrash' => $baseDir . '/../lib/BackgroundJob/ExpireTrash.php',
11
-    'OCA\\Files_Trashbin\\Capabilities' => $baseDir . '/../lib/Capabilities.php',
12
-    'OCA\\Files_Trashbin\\Command\\CleanUp' => $baseDir . '/../lib/Command/CleanUp.php',
13
-    'OCA\\Files_Trashbin\\Command\\Expire' => $baseDir . '/../lib/Command/Expire.php',
14
-    'OCA\\Files_Trashbin\\Command\\ExpireTrash' => $baseDir . '/../lib/Command/ExpireTrash.php',
15
-    'OCA\\Files_Trashbin\\Command\\Size' => $baseDir . '/../lib/Command/Size.php',
16
-    'OCA\\Files_Trashbin\\Controller\\PreviewController' => $baseDir . '/../lib/Controller/PreviewController.php',
17
-    'OCA\\Files_Trashbin\\Events\\MoveToTrashEvent' => $baseDir . '/../lib/Events/MoveToTrashEvent.php',
18
-    'OCA\\Files_Trashbin\\Exceptions\\CopyRecursiveException' => $baseDir . '/../lib/Exceptions/CopyRecursiveException.php',
19
-    'OCA\\Files_Trashbin\\Expiration' => $baseDir . '/../lib/Expiration.php',
20
-    'OCA\\Files_Trashbin\\Helper' => $baseDir . '/../lib/Helper.php',
21
-    'OCA\\Files_Trashbin\\Hooks' => $baseDir . '/../lib/Hooks.php',
22
-    'OCA\\Files_Trashbin\\Migration\\Version1010Date20200630192639' => $baseDir . '/../lib/Migration/Version1010Date20200630192639.php',
23
-    'OCA\\Files_Trashbin\\Sabre\\AbstractTrash' => $baseDir . '/../lib/Sabre/AbstractTrash.php',
24
-    'OCA\\Files_Trashbin\\Sabre\\AbstractTrashFile' => $baseDir . '/../lib/Sabre/AbstractTrashFile.php',
25
-    'OCA\\Files_Trashbin\\Sabre\\AbstractTrashFolder' => $baseDir . '/../lib/Sabre/AbstractTrashFolder.php',
26
-    'OCA\\Files_Trashbin\\Sabre\\ITrash' => $baseDir . '/../lib/Sabre/ITrash.php',
27
-    'OCA\\Files_Trashbin\\Sabre\\PropfindPlugin' => $baseDir . '/../lib/Sabre/PropfindPlugin.php',
28
-    'OCA\\Files_Trashbin\\Sabre\\RestoreFolder' => $baseDir . '/../lib/Sabre/RestoreFolder.php',
29
-    'OCA\\Files_Trashbin\\Sabre\\RootCollection' => $baseDir . '/../lib/Sabre/RootCollection.php',
30
-    'OCA\\Files_Trashbin\\Sabre\\TrashFile' => $baseDir . '/../lib/Sabre/TrashFile.php',
31
-    'OCA\\Files_Trashbin\\Sabre\\TrashFolder' => $baseDir . '/../lib/Sabre/TrashFolder.php',
32
-    'OCA\\Files_Trashbin\\Sabre\\TrashFolderFile' => $baseDir . '/../lib/Sabre/TrashFolderFile.php',
33
-    'OCA\\Files_Trashbin\\Sabre\\TrashFolderFolder' => $baseDir . '/../lib/Sabre/TrashFolderFolder.php',
34
-    'OCA\\Files_Trashbin\\Sabre\\TrashHome' => $baseDir . '/../lib/Sabre/TrashHome.php',
35
-    'OCA\\Files_Trashbin\\Sabre\\TrashRoot' => $baseDir . '/../lib/Sabre/TrashRoot.php',
36
-    'OCA\\Files_Trashbin\\Storage' => $baseDir . '/../lib/Storage.php',
37
-    'OCA\\Files_Trashbin\\Trash\\BackendNotFoundException' => $baseDir . '/../lib/Trash/BackendNotFoundException.php',
38
-    'OCA\\Files_Trashbin\\Trash\\ITrashBackend' => $baseDir . '/../lib/Trash/ITrashBackend.php',
39
-    'OCA\\Files_Trashbin\\Trash\\ITrashItem' => $baseDir . '/../lib/Trash/ITrashItem.php',
40
-    'OCA\\Files_Trashbin\\Trash\\ITrashManager' => $baseDir . '/../lib/Trash/ITrashManager.php',
41
-    'OCA\\Files_Trashbin\\Trash\\LegacyTrashBackend' => $baseDir . '/../lib/Trash/LegacyTrashBackend.php',
42
-    'OCA\\Files_Trashbin\\Trash\\TrashItem' => $baseDir . '/../lib/Trash/TrashItem.php',
43
-    'OCA\\Files_Trashbin\\Trash\\TrashManager' => $baseDir . '/../lib/Trash/TrashManager.php',
44
-    'OCA\\Files_Trashbin\\Trashbin' => $baseDir . '/../lib/Trashbin.php',
9
+    'OCA\\Files_Trashbin\\AppInfo\\Application' => $baseDir.'/../lib/AppInfo/Application.php',
10
+    'OCA\\Files_Trashbin\\BackgroundJob\\ExpireTrash' => $baseDir.'/../lib/BackgroundJob/ExpireTrash.php',
11
+    'OCA\\Files_Trashbin\\Capabilities' => $baseDir.'/../lib/Capabilities.php',
12
+    'OCA\\Files_Trashbin\\Command\\CleanUp' => $baseDir.'/../lib/Command/CleanUp.php',
13
+    'OCA\\Files_Trashbin\\Command\\Expire' => $baseDir.'/../lib/Command/Expire.php',
14
+    'OCA\\Files_Trashbin\\Command\\ExpireTrash' => $baseDir.'/../lib/Command/ExpireTrash.php',
15
+    'OCA\\Files_Trashbin\\Command\\Size' => $baseDir.'/../lib/Command/Size.php',
16
+    'OCA\\Files_Trashbin\\Controller\\PreviewController' => $baseDir.'/../lib/Controller/PreviewController.php',
17
+    'OCA\\Files_Trashbin\\Events\\MoveToTrashEvent' => $baseDir.'/../lib/Events/MoveToTrashEvent.php',
18
+    'OCA\\Files_Trashbin\\Exceptions\\CopyRecursiveException' => $baseDir.'/../lib/Exceptions/CopyRecursiveException.php',
19
+    'OCA\\Files_Trashbin\\Expiration' => $baseDir.'/../lib/Expiration.php',
20
+    'OCA\\Files_Trashbin\\Helper' => $baseDir.'/../lib/Helper.php',
21
+    'OCA\\Files_Trashbin\\Hooks' => $baseDir.'/../lib/Hooks.php',
22
+    'OCA\\Files_Trashbin\\Migration\\Version1010Date20200630192639' => $baseDir.'/../lib/Migration/Version1010Date20200630192639.php',
23
+    'OCA\\Files_Trashbin\\Sabre\\AbstractTrash' => $baseDir.'/../lib/Sabre/AbstractTrash.php',
24
+    'OCA\\Files_Trashbin\\Sabre\\AbstractTrashFile' => $baseDir.'/../lib/Sabre/AbstractTrashFile.php',
25
+    'OCA\\Files_Trashbin\\Sabre\\AbstractTrashFolder' => $baseDir.'/../lib/Sabre/AbstractTrashFolder.php',
26
+    'OCA\\Files_Trashbin\\Sabre\\ITrash' => $baseDir.'/../lib/Sabre/ITrash.php',
27
+    'OCA\\Files_Trashbin\\Sabre\\PropfindPlugin' => $baseDir.'/../lib/Sabre/PropfindPlugin.php',
28
+    'OCA\\Files_Trashbin\\Sabre\\RestoreFolder' => $baseDir.'/../lib/Sabre/RestoreFolder.php',
29
+    'OCA\\Files_Trashbin\\Sabre\\RootCollection' => $baseDir.'/../lib/Sabre/RootCollection.php',
30
+    'OCA\\Files_Trashbin\\Sabre\\TrashFile' => $baseDir.'/../lib/Sabre/TrashFile.php',
31
+    'OCA\\Files_Trashbin\\Sabre\\TrashFolder' => $baseDir.'/../lib/Sabre/TrashFolder.php',
32
+    'OCA\\Files_Trashbin\\Sabre\\TrashFolderFile' => $baseDir.'/../lib/Sabre/TrashFolderFile.php',
33
+    'OCA\\Files_Trashbin\\Sabre\\TrashFolderFolder' => $baseDir.'/../lib/Sabre/TrashFolderFolder.php',
34
+    'OCA\\Files_Trashbin\\Sabre\\TrashHome' => $baseDir.'/../lib/Sabre/TrashHome.php',
35
+    'OCA\\Files_Trashbin\\Sabre\\TrashRoot' => $baseDir.'/../lib/Sabre/TrashRoot.php',
36
+    'OCA\\Files_Trashbin\\Storage' => $baseDir.'/../lib/Storage.php',
37
+    'OCA\\Files_Trashbin\\Trash\\BackendNotFoundException' => $baseDir.'/../lib/Trash/BackendNotFoundException.php',
38
+    'OCA\\Files_Trashbin\\Trash\\ITrashBackend' => $baseDir.'/../lib/Trash/ITrashBackend.php',
39
+    'OCA\\Files_Trashbin\\Trash\\ITrashItem' => $baseDir.'/../lib/Trash/ITrashItem.php',
40
+    'OCA\\Files_Trashbin\\Trash\\ITrashManager' => $baseDir.'/../lib/Trash/ITrashManager.php',
41
+    'OCA\\Files_Trashbin\\Trash\\LegacyTrashBackend' => $baseDir.'/../lib/Trash/LegacyTrashBackend.php',
42
+    'OCA\\Files_Trashbin\\Trash\\TrashItem' => $baseDir.'/../lib/Trash/TrashItem.php',
43
+    'OCA\\Files_Trashbin\\Trash\\TrashManager' => $baseDir.'/../lib/Trash/TrashManager.php',
44
+    'OCA\\Files_Trashbin\\Trashbin' => $baseDir.'/../lib/Trashbin.php',
45 45
 );
Please login to merge, or discard this patch.