diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2019-11-04 18:18:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-04 18:18:32 +0100 |
commit | 13960b69da2593dcfb0cbaef222ee8b9a33142c0 (patch) | |
tree | ca43ed0f4daa75e6b03b137b3ad650c8b721efa7 /apps/files_trashbin/lib | |
parent | 64bfd4bbeb10e07bd2133a97c50175a156d43d61 (diff) | |
parent | 964dc0a95520efbf876e0113bfafc294f4f4b322 (diff) | |
download | nextcloud-server-13960b69da2593dcfb0cbaef222ee8b9a33142c0.tar.gz nextcloud-server-13960b69da2593dcfb0cbaef222ee8b9a33142c0.zip |
Merge pull request #17509 from nextcloud/fix/application-singleton
Fix Application instances created multiple times
Diffstat (limited to 'apps/files_trashbin/lib')
-rw-r--r-- | apps/files_trashbin/lib/AppInfo/Application.php | 7 | ||||
-rw-r--r-- | apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php | 3 | ||||
-rw-r--r-- | apps/files_trashbin/lib/Expiration.php | 6 | ||||
-rw-r--r-- | apps/files_trashbin/lib/Trashbin.php | 10 |
4 files changed, 14 insertions, 12 deletions
diff --git a/apps/files_trashbin/lib/AppInfo/Application.php b/apps/files_trashbin/lib/AppInfo/Application.php index 4baa82a6b4b..a2613a13b41 100644 --- a/apps/files_trashbin/lib/AppInfo/Application.php +++ b/apps/files_trashbin/lib/AppInfo/Application.php @@ -46,12 +46,7 @@ class Application extends App { /* * Register expiration */ - $container->registerService('Expiration', function($c) { - return new Expiration( - $c->query('ServerContainer')->getConfig(), - $c->query(ITimeFactory::class) - ); - }); + $container->registerAlias('Expiration', Expiration::class); /* * Register $principalBackend for the DAV collection diff --git a/apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php b/apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php index e19b7ce604f..919317a7b7a 100644 --- a/apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php +++ b/apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php @@ -62,7 +62,8 @@ class ExpireTrash extends \OC\BackgroundJob\TimedJob { } protected function fixDIForJobs() { - $application = new Application(); + /** @var Application $application */ + $application = \OC::$server->query(Application::class); $this->userManager = \OC::$server->getUserManager(); $this->expiration = $application->getContainer()->query('Expiration'); } diff --git a/apps/files_trashbin/lib/Expiration.php b/apps/files_trashbin/lib/Expiration.php index c7ad4e29f18..933375c9537 100644 --- a/apps/files_trashbin/lib/Expiration.php +++ b/apps/files_trashbin/lib/Expiration.php @@ -49,7 +49,11 @@ class Expiration { public function __construct(IConfig $config,ITimeFactory $timeFactory){ $this->timeFactory = $timeFactory; - $this->retentionObligation = $config->getSystemValue('trashbin_retention_obligation', 'auto'); + $this->setRetentionObligation($config->getSystemValue('trashbin_retention_obligation', 'auto')); + } + + public function setRetentionObligation(string $obligation) { + $this->retentionObligation = $obligation; if ($this->retentionObligation !== 'disabled') { $this->parseRetentionObligation(); diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php index a06a5145d99..34138c21705 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -747,7 +747,8 @@ class Trashbin { */ private static function scheduleExpire($user) { // let the admin disable auto expire - $application = new Application(); + /** @var Application $application */ + $application = \OC::$server->query(Application::class); $expiration = $application->getContainer()->query('Expiration'); if ($expiration->isEnabled()) { \OC::$server->getCommandBus()->push(new Expire($user)); @@ -764,7 +765,8 @@ class Trashbin { * @return int size of deleted files */ protected static function deleteFiles($files, $user, $availableSpace) { - $application = new Application(); + /** @var Application $application */ + $application = \OC::$server->query(Application::class); $expiration = $application->getContainer()->query('Expiration'); $size = 0; @@ -791,8 +793,8 @@ class Trashbin { * @return integer[] size of deleted files and number of deleted files */ public static function deleteExpiredFiles($files, $user) { - $application = new Application(); - $expiration = $application->getContainer()->query('Expiration'); + /** @var Expiration $expiration */ + $expiration = \OC::$server->query(Expiration::class); $size = 0; $count = 0; foreach ($files as $file) { |